in

James Mann's Blog

Enumerate web applications on a sharepoint farm

To enumerate site collections on a farm:
SPWebService contentService = SPWebService.ContentService;

foreach(SPWebApplication app in contentService.WebApplications) 
{
  if (app.Sites.Count > 0) 
  {
    // pick the first site (root site)
    SPSite rootSite = app.Sites[0];
    
    Trace.WriteLine(site.Url);
  }
}

Comments

No Comments

Leave a Comment

(required)  
(optional)
(required)  
Add
Black Marble 2004-2009
Powered by Community Server (Commercial Edition), by Telligent Systems