自动创建图片库、文档库
创建图片库
SPListTemplateCollection ListCollection = web.ListTemplates;
SPListTemplate ListTemp = null;
for (int i = 0; i < ListCollection.Count; i++)
{
if (ListCollection[i].Type.ToString() == "PictureLibrary")
{
ListTemp = ListCollection[i];
break;
}
}
web.Lists.Add(listname, "文档库说明", ListTemp);
创建文档库
SPListTemplateCollection ListCollection = web.ListTemplates;
SPListTemplate ListTemp = null;
for (int i = 0; i < ListCollection.Count; i++)
{
if (ListCollection[i].Type.ToString() == "DocumentLibrary")
{
ListTemp = ListCollection[i];
break;
}
}
SPDocTemplate Doctemp = null;
SPDocTemplateCollection docCollection = web.DocTemplates;
foreach (SPDocTemplate Temp in docCollection)
{
if (Temp.Name.Contains("Microsoft Office Word 97-2003 文档"))
{
Doctemp = Temp;
break;
}
}
web.Lists.Add(listname, "文档库说明", ListTemp, Doctemp);
根据SPListTemplate Type 可以获取生成模板