我是 Sharepoint 2010 的新手,但对 .Net 编程并不陌生。这是我的情况,我有大量文件要上传到带有元数据的 Sharepoint 2010。我决定编写一个 C# 类库以编程方式处理文档集。我必须使用 DocumentSets,并且我能够成功创建一个文档集。现在我坚持以下几点:
- 如何检查文档集是否已经存在?
- 如何删除文档集?
这是我创建文档集的代码:
using (SPSite site = new SPSite(spURL))
{
using (SPWeb web = site.OpenWeb())
{
SPList docs = web.Lists["Documents"];
if (docs != null)
{
SPContentType docSetCT = docs.ContentTypes["Document Set"];
if (docSetCT != null)
{
Hashtable docsetProps = new Hashtable();
docsetProps.Add("New Docset", "New Docset");
DocumentSet docSet = DocumentSet.Create(docs.RootFolder, documentSetName, docSetCT.Id, docsetProps, true);
docs.Update();
}
}
}
}