我使用下面的代码,给了我两个列表和文档库; 但我想只得到文档库的列表。 请帮助我如何区分编程列表和文档库
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>");
}
}
}
文章来源: How to get list of all document libraries from sharepoint site programatically