example -
SPList oList = oWebsiteRoot.Lists["Document_Library_Name"];
SPFolder oFolder = oList.RootFolder.SubFolders["Folder_Name"];
SPQuery oQuery = new SPQuery();
oQuery.Folder = oFolder;
SPListItemCollection collListItems = oList.GetItems(oQuery);
Using FilesOnly attribute with SPquery - FilesOnly will get all the files of a specific folder.
SPList oList = oWebsiteRoot.Lists["Document_Library_Name"];
SPFolder oFolder = oList.RootFolder.SubFolders["Folder_Name"];
SPQuery oQuery = new SPQuery();
oQuery.Folder = oFolder;
query.ViewAttributes = "Scope=\"FilesOnly\"";
SPListItemCollection collListItems = oList.GetItems(oQuery);
Using Recursive attribute - Show all files and all subfolders of all folders.
SPList oList = oWebsiteRoot.Lists["Document_Library_Name"];
SPFolder oFolder = oList.RootFolder.SubFolders["Folder_Name"];
SPView view = list.Views["View_Name"];
SPQuery oQuery = new SPQuery(view);
oQuery.ViewAttributes = "Scope=\"Recursive\"";
SPListItemCollection myItems = list.GetItems(oQuery);
Using RecursiveAll attribute - Show all files and all subfolders of all folders.
SPList oList = oWebsiteRoot.Lists["Document_Library_Name"];
SPFolder oFolder = oList.RootFolder.SubFolders["Folder_Name"];
SPView view = list.Views["View_Name"];
SPQuery oQuery = new SPQuery(view);
oQuery.ViewAttributes = "Scope=\"RecursiveAll\"";
SPListItemCollection myItems = list.GetItems(oQuery);
Ads by Google
So are you saying there is no difference between "Recursive" and "RecursiveAll"?
ReplyDeleteusing "RecursiveAll" will all include the folders in the result.
ReplyDelete"Recursive" only returns the files in folders and subfolders.
This is very confusing. RecursiveAll for the root folder behaves different as if the query is for a subfolder. Add to injury that every "Caml Query Tool" available is extremely buggy.
ReplyDelete