I have a sharepoint list like that:
List
---------Folder 1
-----------------Item 1
-----------------Item 2
---------Folder 2
-----------------Item 1
-----------------Item 2
---------Folder 3
-----------------Item 1
-----------------Item 2
How can I get all Folders in
List
?After that checking if current user has
Contribute
permission onFolder 1
,Folder 2
,Folder 3
?
To get the list of folders of a list you can use the
Folders
property of theSPList
object:To check if a given user has Contribute permission on a folder you need to get the
SPListItem
associated with theSPFolder,
check for aRoleAssignment
of the given user and check itsRoleDefinitionBindings
for the Contribute Role Definition:Usage example