Create site from template




Go back to index

How to create site from template site


Following code block explains how to create a site collection from a template site collection

      using System;
      using SPTool.Library;
      using System.Collections.ObjectModel;
 
      namespace SPTool.Test
      {
          class Program
          {
              static void Main(string[] args)
              {
                  SPTFarm farm = new SPTFarm();

                  // Create site collection from template site
                  SPTReturn returnObj = farm.CreateSiteFromTemplateSite("http://sptool/", "http://sptool:90", "New site title", "New site description",
                      true, Path.Combine(SPTHelper.Paths._SPTool, "Temp"));

                  // Check the status of site collection creation
                  if (returnObj.State == SPTState.Success)
                  {
                      // Successfully created site collection from template site
                  }
                  else
                  {
                      // Creating site collection failed
                  }
              }
          }
      }


Go back to index