Programmatically get all files in a document set sharepoint 2010

To Programmatically retrieve files in a DocumentSet -

* We will first check if its a item or a Folder.
* Then check if its a DocumentSet of a SPFolder.
* At last Retrive the files in the document set.

bool _isDocumentset = IsDocumentSet(_item)

public static bool IsDocumentSet(this SPListItem item)

{

bool documentSetItem = false;

DocumentSet documentSet = null;

if (null != item && item.IsFolder())

{

documentSet = DocumentSet.GetDocumentSet(item.Folder);

if (null != documentSet)

documentSetItem = true;

}

return documentSetItem;

}



3. If document set then get its files

if(isDocumentset)

{

SPFolder documentsetFolder = _item.Folder;

SPFile file = documentsetFolder.Files[0]; -> Get files

}

0 comments:

Post a Comment

Disclaimer

This is a personal weblog. The opinions expressed here represent my own and not those of my employer or anyone else. Should you have any questions or concerns please e-mail me at sharepointprogrammingblogger@gmail.com .

Copyright (c) 2010 @ myshaepointwork.blogspot.com. All rights are reserved.Do Not Copy.

@ Learning SharePoint.com