//using Microsoft.SharePoint.Client;
//using Microsoft.Online.SharePoint.TenantAdministration;
//string weburl = "https://site.sharepoint.com";
//GetSite(credentials, weburl);
//This method returns the site collection object based on the url.
//shows the count of all subwebs available with in SharePoint online Site Collection
//Microsoft.Online.SharePoint.TenantAdministration.SiteProperties.WebsCount property
private static void GetSite(SharePointOnlineCredentials credentials, string weburl)
{
using (ClientContext ctx = new ClientContext(weburl))
{
ctx.Credentials = credentials;
Tenant tenant = new Tenant(ctx);
//weburl is the SharePoint Site url
//true - includes all properties of the Site Collection in the request
SiteProperties ositeProperties = tenant.GetSitePropertiesByUrl(weburl, true);
ctx.Load(ositeProperties);
ctx.ExecuteQuery();
Console.WriteLine("Total webs: " + ositeProperties.WebsCount);
}
Console.WriteLine("Press any key to exit...");
Console.Read();
}This code snippet used to get the site collection object based on the url and the count of all subwebs available with in SharePoint online Site Collection.
