using Microsoft.SharePoint; ... SPSite site = new SPSite("http://mysharepointsite"); SPWeb web = site.RootWeb; string title = web.Title; string description = web.Description; string url = web.Url;
using Microsoft.SharePoint; ... SPWeb web = new SPSite("http://mysharepointsite").RootWeb; foreach (SPWeb subWeb in web.Webs) { Console.WriteLine(subWeb.Title); }
using Microsoft.SharePoint; ... SPWeb parentWeb = new SPSite("http://mysharepointsite").RootWeb; string newWebUrl = parentWeb.Url + "/newsubsite"; SPWeb newWeb = parentWeb.Webs.Add(new WebCreationInformation { Url = newWebUrl, Title = "New Subsite", Description = "This is a new subsite" });This example uses the Webs.Add method of an SPWeb object to create a new subsite under the root web of a SharePoint site, with a specified URL, title, and description. Package library: Microsoft.SharePoint.dll