Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I need to find out how many subitems and subfolders a SPListItem has. The fields ItemChildCount and FolderChildCount are no solution for me, because they only count the folder/item directly beneath the ListItem. I need ALL items and folders.

Is there a way to get these numbers without iterating through the complete list?

Thanks in advance :)

LMW

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Items + Folder count

Can you check out whether SPFolder.Itemcount could help to get the number of items in a list including the subfolders? - http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfolder_members.aspx

Only Item Count

Then checking the SPListItemCollection.Count will give you the list items excluding the folders. - http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splistitemcollection_members.aspx

Difference of both might give you the number of folders in the list. I couldnt find a direct method to get all the folders and subfolders in a list.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.