Export (0) Print
Expand All

DocumentSet.Create Method (SPFolder, String, SPContentTypeId, Hashtable)

SharePoint 2010

Creates a new DocumentSet object.

Namespace:  Microsoft.Office.DocumentManagement.DocumentSets
Assembly:  Microsoft.Office.DocumentManagement (in Microsoft.Office.DocumentManagement.dll)

public static DocumentSet Create(
	SPFolder parentFolder,
	string name,
	SPContentTypeId ctid,
	Hashtable properties


Type: Microsoft.SharePoint.SPFolder
The folder that contains the DocumentSet object.
Type: System.String
The name of the new DocumentSet object.
Type: Microsoft.SharePoint.SPContentTypeId
The content type identifier on which to base the new DocumentSet object.
Type: System.Collections.Hashtable
The properties of the new DocumentSet object.

This method tries to assign any values found in the hashtable to the appropiate fields in the new DocumentSet object. The values are copied to the new object only if they are valid fields present in the content type. Values for unknown fields are ignored.

The code example creates a new document set in the root folder of a specified list. The example assumes that the Description and Project Client columns used in the properties hashtable are already defined at the site level.

Namespace references:

  • Microsoft.Office.DocumentManagement.DocumentSets

  • Microsoft.SharePoint

  • System.Web

            //Get the folder into which to insert the document set.
            SPWeb web = new SPSite("URL_of_Site_for_DocSet").OpenWeb();
            SPList list = web.Lists["List_Name_for_DocSet"];
            SPFolder folderToInsertIn = list.RootFolder;

            //Get the content type ID for the specified document set content type.
            SPContentTypeId dsCtId = new SPContentTypeId();
            dsCtId = list.ContentTypes["DocumentSet_ContentType_Name"].Id;

            // Create the Document Set Properties HashTable
            Hashtable properties = new Hashtable();
            properties.Add("Description", "Project Description");
            properties.Add("Project Client", "AdventureWorks");

            //Create the new Document Set object.
            DocumentSet.Create(folderToInsertIn, "New_DocumentSet_Name", dsCtId, properties, true);

Community Additions

© 2014 Microsoft