我正在使用下面的代码,它给了我列表&文件库;但我想获取只有文档库的列表。
请帮助我如何区分列表和&文档库以编程方式
using(SPSite oSite = new SPSite("https://server/site"))
{
using (SPWeb oWeb = oSite.OpenWeb())
{
SPListCollection oLists = oWeb.Lists;
foreach (SPList olist in oLists)
{
Response.Write(olist.Title+"<br>");
}
}
}
答案 0 :(得分:8)
请参阅this Post
using(SPSite oSite = new SPSite("https://server/site"))
{
using (SPWeb oWeb = oSite.OpenWeb())
{
SPListCollection docLibraryColl = oWeb.GetListsOfType(SPBaseType.DocumentLibrary);
foreach (SPList list in docLibraryColl)
{
Response.Write(list.Title+"<br>");
}
}
}
希望它的帮助!!
答案 1 :(得分:3)
尝试这样的事情
using(SPSite oSite = new SPSite("https://server/site"))
{
using (SPWeb oWeb = oSite.OpenWeb())
{
SPListCollection oLists = oWeb.Lists;
foreach (SPDocumentLibrary olist in oLists.OfType<SPDocumentLibrary>())
{
Response.Write(olist.Title+"<br>");
}
}
}