Share via

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

Creates a new DocumentSet object.

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


Public Shared Function Create ( _
    parentFolder As SPFolder, _
    name As String, _
    ctid As SPContentTypeId, _
    properties As Hashtable _
) As DocumentSet
Dim parentFolder As SPFolder
Dim name As String
Dim ctid As SPContentTypeId
Dim properties As Hashtable
Dim returnValue As DocumentSet

returnValue = DocumentSet.Create(parentFolder, _
    name, ctid, properties)
public static DocumentSet Create(
    SPFolder parentFolder,
    string name,
    SPContentTypeId ctid,
    Hashtable properties


Return value

Type: Microsoft.Office.DocumentManagement.DocumentSets.DocumentSet
The new DocumentSet object.


This version of the Create method always provisions default contents for the content type, if default contents exist.

This method tries to assign any values found in the hash table to the appropriate 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 hash table are already defined at the site level.

Namespace references:

            //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);

See also


DocumentSet class

DocumentSet members

Create overload

Microsoft.Office.DocumentManagement.DocumentSets namespace