Hi All,
Many times we require getting all documents in the entire document library including sub folders. For this we need to use the ViewAttributes property on SPQuery object and set it to specify Scope=\"Recursive\
If we don’t do this, then result we will get it all documents from the top folder only.
Here is a simple way, we will achieve this.
Sometimes we may require returning the result from specific folder inside the document library.
At this time, we need to use SPFolder class and set the SPQuery object’s Folder property to the object of SPFolder.
Here is a way.
Many times we require getting all documents in the entire document library including sub folders. For this we need to use the ViewAttributes property on SPQuery object and set it to specify Scope=\"Recursive\
If we don’t do this, then result we will get it all documents from the top folder only.
Here is a simple way, we will achieve this.
SPList objList = objWeb.Lists["{name of the doc lib}"];
SPView objView = objList.Views["name of the view"];
SPQuery objQuery = new SPQuery(objView);
objQuery.ViewAttributes = "Scope=\"Recursive\"";
SPListItemCollection objItemColl = objList.GetItems(objQuery);
Sometimes we may require returning the result from specific folder inside the document library.
At this time, we need to use SPFolder class and set the SPQuery object’s Folder property to the object of SPFolder.
Here is a way.
SPFolder objFolder = objList.RootFolder.SubFolders["name of the folder"];That is it. Your job is done.
objQuery.Folder = objFolder
No comments:
Post a Comment