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 :)


1 Answer 1


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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