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

}

2 comments:

  1. Borgata Hotel Casino & Spa: Employee Reviews & Overview
    The 군포 출장마사지 Borgata Hotel Casino 오산 출장안마 & Spa has a restaurant, 남원 출장샵 casino and spa. The casino was very nice. 김해 출장샵 You'll never go to a 구미 출장마사지 pool or go to a bar. They  Rating: 4 · ‎1 review

    ReplyDelete

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