编程方式删除网站资产库中的内容类型- SharePoint 2010

一条通过SharePoint 2010对象模型删除网站资产库中默认的内容类型并添加你自己的自定义内容类型小技巧。网站资产库中默认包含的内容类型是Audio,Video和Image.

SPSite oSite = new SPSite(“http://blrs2r8-11″);
SPWeb oWeb = oSite.OpenWeb();
SPListTemplate Otemplate = oWeb.ListTemplates["Asset Library"];
SPList oList = oWeb.Lists[oWeb.Lists.Add("NewList", "New List from Code", Otemplate)];
oList.ContentTypes["Video"].Delete();
oList.ContentTypes["Audio"].Delete();
oList.ContentTypes["Image"].Delete();
SPContentType oCtype = oWeb.ContentTypes["Custom Content Type"];
oList.ContentTypes.Add(oCtype);
oList.Update();

参考资料

Delete Content Types in Asset Library Programmatically- SharePoint 2010

posted @ 2010-10-08 14:00  Sunmoonfire  阅读(152)  评论(0)    收藏  举报