Programmatically Get Document Set for a document SharePoint 2010

The Code below checks Whether the document item "itemToCheck" belongs to any document set and if yes it returns the document set name.

public bool IsDocumentSetItem(SPListItem itemToCheck)

bool documentSetItem = false;

if (itemToCheck.File != null)
DocumentSet documentSet;

documentSet = DocumentSet.GetDocumentSet(itemToCheck.File.ParentFolder);

if (null != documentSet)
documentSetItem = true;
return documentSetItem;

The code asks the current item to return the containing set. If there is no set, then the item is not part of any document set.


Post a Comment


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 .

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

@ Learning