Shantha Kumar T
SharePoint is the platform where we can store the set of values as items, files as documents in folder or Library. But how we manage all the data’s, there comes Web sites. The above collection of web sites are managed by Site Collection, which is a placeholder or container for all the web sites.
Here I am enroll the snippet for enumerating the all the site collections from the web application. This Web Application is nothing but a IIS Site and has some specific properties helps to manage the Collection of Site Collections.
//Retrieving the webapplication based on Url
SPWebApplication webapps = SPWebApplication.Lookup(new Uri(“http://localhost”));
//Gets all the sites under the WebApplication
SPSiteCollection sites = webapps.Sites;
//Iterating the site collection and printing
foreach (SPSite s in sites)
//Disposing the SiteCollection object, use to clears the memory obtained for SPSite object