Get Every List in a Site Collection
This is from a forum post.
Remember, the SPSite represents a site collection. The SPWeb represents a site. SPSite.AllWebs flattens the site hierarchy and returns all site. SPWeb.Lists returns all lists in a site.
using (SPSite site = new SPSite("url") {
foreach (SPWeb web in site.AllWebs) {
foreach (SPList list in web.Lists) {
// do something...
}
web.Dispose();
}
}
Remember, the SPSite represents a site collection. The SPWeb represents a site. SPSite.AllWebs flattens the site hierarchy and returns all site. SPWeb.Lists returns all lists in a site.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home