我有一個SharePoint網站。我正在嘗試打開一個子網站並獲取該子網站中所有列表的列表。此代碼返回頂級「http:// myspserver」列表。
如何獲取/ mysubsite中的列表?SharePoint子網站 - 遍歷列表
string webUrl = "http://myspserver/mysubsite";
using (SPWeb oWebsite = new SPSite(webUrl).OpenWeb()) //Open SP Web
{
SPListCollection collList = oWebsite.Lists; //Open Lists
foreach (SPList oList in SPContext.Current.Web.Lists)
//For Each List Execute this
{
....
}
}
也許這可以幫助HTTP ://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.getlist.aspx – 2011-02-16 15:56:54