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)

Syntax

'Declaration
Public Shared Function Create ( _
    parentFolder As SPFolder, _
    name As String, _
    ctid As SPContentTypeId, _
    properties As Hashtable _
) As DocumentSet
'Usage
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
)

Parameters

Return Value

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

Remarks

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.

Examples

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

See Also

Reference

DocumentSet Class

DocumentSet Members

Create Overload

Microsoft.Office.DocumentManagement.DocumentSets Namespace