SPSite site = new SPSite(“<top level site URL>”);//http://MySite:12345
SPWeb web = site.OpenWeb();//makes connection and opens the site to allow modification
web.AllowUnsafeUpdates = true;//Security setting that allows you to add to / modify the site
SPWebCollection subsite = web.Webs;//creates context in the site to create a new subsite
SPWeb newSubWeb = subsite.Add(“TestNewSite”,//subsite URL
  “Title”,//subsite Title
  “Description”,//subsite Description
  1033,//subsite Language code
  “STS#0”,//subsite Template
  false,//true to create with unique permissions, false to inherit parent permissions
  false);//true converts existing folder with same name to a SP site, false throws exception if site name exists.

For reference on MS – http://msdn2.microsoft.com/en-us/library/ms412285.aspx

Advertisements