在sharepoint server 2010中以编程方式创建文档集

时间:2011-02-22 10:28:54

标签: sharepoint set document

如何在sharepoint server 2010中以编程方式在文档库中创建文档集?

2 个答案:

答案 0 :(得分:4)

如果您想使用客户端对象模型:

{
      ClientContext clientContext = new ClientContext("http://<<SERVER_NAME>>");

      Web site = clientContext.Web;

      // Create a list.
      ListCreationInformation listCreationInfo =
        new ListCreationInformation();
      listCreationInfo.Title = "Document Library";
      listCreationInfo.TemplateType = (int)ListTemplateType.DocumentLibrary;
      List list = site.Lists.Add(listCreationInfo);

      // Enable Content Types on list
      list.ContentTypesEnabled = true;

      // Update List Configuration
      list.Update();

      // Send it to SharePoint
      clientContext.ExecuteQuery();

      // Get Content Type Document Set ID = 0x0120D520
      ContentType ctx = clientContext.Site.RootWeb.AvailableContentTypes.GetById("0x0120D520");

      // Add Existing To List
      list.ContentTypes.AddExistingContentType(ctx);

      // Execute
      clientContext.ExecuteQuery();
}

答案 1 :(得分:1)

http://msdn.microsoft.com/en-us/library/gg581064.aspx

然后添加该内容类型的项目。