我使用下面的代码,这给了我两个列表&文档库;但我正试图获得只有文档库的列表。请帮我如何区分列表&程序化文档库
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>");
}
}
}
看这篇文章
试试这个方法:
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>");
}
}
}
希望有帮助!!
试试这样
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>");
}
}
}