While working on one of the requirement in my project , I need to show the files in Root Folder of Document library only not from child folders within it.
Through "Folder" option in default view, I can only set to show the folder or show files without folder.
But through code we will get all the files in root folder as well as in child folder also.
To resolve this, you need to use Scope="FilesOnly" for the ViewAttributes property of the SPQuery.
SPList list = _oWeb.Lists["Library Name"];
SPQuery spQuery = new SPQuery();
spQuery.ViewAttributes = "Scope=\"FilesOnly\"";
SPListItemCollection items = list.GetItems(spQuery);
No comments:
Post a Comment