Create Site Template Pro-grammatically

We have many a time saved a SharePoint site template using the SharePoint User Interface. But did you know that we can save the site template pro-grammatically as well. Let me tell you how…

using(SPSite siteCollection = new SPSite("http://{yoursite}"))
{ 
  using(SPWeb web = siteCollection.RootWeb)
  {
    web.SaveAsTemplate("TemplateFileName.stp", "Template Title", "Template Description.", true);
  }
}

Related Post

Leave a Reply

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