I have a List that stores items in a folder hierarchy.
I notice that SPFolder.Files.Count is always zero.
Is there a way to find out how many list items are there in a folder?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I presume you are looking for direct children and not descendants (like items within a sub-folder).
Do you also want to include sub-folders in the count? In which case you can use:
SPFolder.ItemCount.If you just want only the direct child listItems which are not subfolders then you can do something like the following:
I haven’t tried it. You might have to add a where clause to eliminate folders, if the query is returning that.
If you want to include all list-items, even within subfolders, set the
SPQuery.ViewAttributesfield asquery.ViewAttributes = "Scope=\"Recursive\"";