I've been trying to use the method shown here:
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splistcollection.aspx
However, I'm getting this error on line 2 below:
Microsoft.SharePoint.SPWebCollection: type used in a using statement must be implicitly convertible to 'System.IDisposable'
SPSite oSiteCollection = SPContext.Current.Site;
using(SPWebCollection collWebs = oSiteCollection.AllWebs)
{
foreach (SPWeb oWebsite in collWebs)
{
SPListCollection collSiteLists = oWebsite.Lists;
foreach (SPList oList in collSiteLists)
{
Label1.Text += SPEncode.HtmlEncode(oWebsite.Name) + " :: " +
SPEncode.HtmlEncode(oList.Title) + "<BR>";
}
oWebsite.Dispose();
}
}
It won't allow SPWebCollection to be used in a using statement, because it doesn't inherit IDisposable.
Did MSDN make an error, or am I missing something?