How to get list of sub sites using SharePoint client object model

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client.Utilities;

private static void GetAllSubSites()
{
ClientContext clientContext = new ClientContext(“http://{yoursiteurl}/“);
Web oWebsite = clientContext.Web;
clientContext.Load(oWebsite,
website => website.Webs,
website => website.Title
);
clientContext.ExecuteQuery();
Console.WriteLine(“Available sites Count: ” + oWebsite.Webs.Count);
for (int i = 0; i != oWebsite.Webs.Count; i++)
{
Console.WriteLine(“Site Title: “+ oWebsite.Webs[i].Title);
}
}

Related Post

3 thoughts on “How to get list of sub sites using SharePoint client object model”

Leave a Reply

Your email address will not be published. Required fields are marked *