自动创建图片库、文档库

创建图片库

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 可以获取生成模板

posted @ 2010-06-24 08:33  Anlycp  阅读(402)  评论(1编辑  收藏  举报