如果你創建自己的內容類型,並在發佈/啓動到SharePoint,那麼就應該是可供您添加到文檔庫。只要確保您的文檔庫已配置爲支持內容類型。
在文檔庫設置的高級設置部分,在Allow management of content types?
下選擇Yes
然後按照原樣繼續。 設置 - >添加從現有網站內容類型..
您可以使用一個控制檯應用程序(REF MSDN)內容類型添加到列表中的網站。它還爲您提供有關當前事物狀態的有用信息。
class Program {
static void Main(string[] args) {
using (SPSite siteCollection = new SPSite("http://YOUR_SPSITE")) {
using (SPWeb site = siteCollection.OpenWeb() {
// Get a content type.
SPContentType ct = site.AvailableContentTypes["YOUR_CONTENT_NAME"];
// The content type was found.
if (ct != null)
// Get a list.
try {
SPList list = site.Lists["YOUR_DOCUMENT_LIBRARY_NAME"]; // Throws exception if does not exist.
// Make sure the list accepts content types.
list.ContentTypesEnabled = true;
// Add the content type to the list.
if (!list.IsContentTypeAllowed(ct))
Console.WriteLine("The {0} content type is not allowed on the {1} list",
ct.Name, list.Title);
else if (list.ContentTypes[ct.Name] != null)
Console.WriteLine("The content type name {0} is already in use on the {1} list",
ct.Name, list.Title);
else
list.ContentTypes.Add(ct);
}
catch (ArgumentException ex) // No list is found.
{
Console.WriteLine("The list does not exist.");
}
else // No content type is found.
Console.WriteLine("The content type is not available in this site.");
}
}
Console.Write("\nPress ENTER to continue...");
Console.ReadLine();
}
}
看一看使用SharePoint管理網站。它會明確告訴你文件夾內容類型是否已更改。 – Nat 2011-03-28 20:43:08