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 want to select the list of folders (without subfolders, not recursive) of a Document library using CrossListQueryCache.

Everything is working fine except that i am receiving ALL the folders and subfolders in the list and not just the first level of folders. what do i need to change in the code below so that only the first level of folders is returned without their subfolders and sub-subfolders etc...

string query = string.Empty; 
string websQuery = string.Format("<Webs Scope=\"{0}\"/>", "None"); 
string lists = "<Lists ServerTemplate=\"101\"" + " ><List ID=\"" + listid + "\" /></Lists>";   
bool useList = true; 
string relativeUrl = this.GetRelativeUrl(); 
query = string.Format("<Where><Eq><FieldRef Name='FSObjType' /><Value Type='LookUp'>1</Value></Eq></Where>", relativeUrl);   
CrossListQueryInfo info = new CrossListQueryInfo(); 
info.Lists = lists; 
info.Webs = websQuery; 
info.Query = query; 
info.ViewFields = "<FieldRef Name=\"FileLeafRef\"/>"; 
info.WebUrl = web.ServerRelativeUrl; 
CrossListQueryCache cache = new CrossListQueryCache(info); 
SiteDataResults sd = cache.GetSiteDataResults(site, true); 
share|improve this question
    
Even after FileDirRef and the List Name it din't work for me –  user15530 Mar 13 '13 at 6:35
add comment

1 Answer 1

I really don't see a way you can do this...not with a CrossListQuery anyway. If you were doing this against a single list (i.e. SPList.GetItems(SPQuery) then you could add:

<Eq><FieldRef Name='FileDirRef'/><Value Type='Text'>"ListName"</Value></Eq>

and that would pull back only the top level folders, as the folders under that would have a FileDirRef of "ListName\TopLevelFolder" and so on.

share|improve this answer
1  
Yeah, just don't include Scope="Recursive" like you normally would. –  Kit Menke Aug 4 '11 at 19:11
add comment

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.