The AllWebs property of the SPSite class returns all the Web sites within a site collection, including the top-level site and all subsites. The following example enumerates the titles of all the Web sites and lists in the current site collection.
SPSite oSiteCollection = SPContext.Current.Site; SPWebCollection collWebsite = oSiteCollection.AllWebs; for (int i = 0; i < collWebsite.Count; i++) { using (SPWeb oWebsite = collWebsite[i]) { SPListCollection collList = oWebsite.Lists; for (int j = 0; j < collList.Count; j++) { Label1.Text += SPEncode.HtmlEncode(collWebsite[i].Title) + " " + SPEncode.HtmlEncode(collList[j].Title) + "<BR>"; } } }