I\'m trying to write a CAML query that executes against a specific SPList, scoped to a specific folder, recursive from that point, and returns all ListItems (which meet a cr
Everyone is close, but not quite right.
using (SPSite site = new SPSite("http://server/site"))
{
SPWeb web = site.RootWeb; // See disposal guidance http://blogs.msdn.com/b/rogerla/archive/2008/10/04/updated-spsite-rootweb-dispose-guidance.aspx
SPQuery query = new SPQuery();
query.Query = @"
0x0120
";
query.ViewAttributes = "Scope='RecursiveAll'";
SPList list = web.Lists[listId];
SPListItemCollection items = list.GetItems(query);
// Do stuff with your folders
}
First of all, using this FieldRef is wrong:
Folder
because the folder content type can be inherited. Therefore, you need to compare against the content type ID, like this:
0x0120
And then, set the view attribute Scope to RecursiveAll
...
That should return any item whose content type inherits from Folder (0x0120)