We are using below code to get the documents in a specific folder. Code works OK
for 2 doclibs (it returns the documents based on security permissions of the
documents), however with one of our doclibs, it returns all of the documents
regardless of their security permissions. Doclib contains more than 1000
documents with major versioning enabled.
private SPListItemCollection getListItemsInDocLib(string listName, string
viewName)
{
SPWeb web = SPContext.Current.Web;
SPList listBD = web.Lists[listName];
SPDocumentLibrary doclib = (SPDocumentLibrary)listBD;
SPView viewBD = listBD.Views[viewName];
SPFolder folder = null;
foreach (SPListItem item in listBD.Folders)
{
if (Yil.Equals("2009"))
{
folder = item.Folder;
break;
}
}
SPListItemCollection listCollection = null;
if (folder != null)
listCollection = doclib.GetItemsInFolder(viewBD, folder);
return listCollection;
}
doclib.GetItemsInFolder(viewBD, folder) or doclib.GetItems(viewBD) returns the
same result.
Have you ever experienced something like this?