public static SPFile UploadWebTemplate(string siteUrl, string templatePath)

{

using (SPSite site = new SPSite(siteUrl))

{

SPDocumentLibrary templates = (SPDocumentLibrary)site.GetCatalog(SPListTemplateType.WebTemplateCatalog);

 

System.IO.FileInfo fileInfo = new System.IO.FileInfo(templatePath);

byte[] bytes = System.IO.File.ReadAllBytes(fileInfo.FullName);

 

return templates.RootFolder.Files.Add(fileInfo.Name, bytes);

}

}

LEAVE A REPLY

Please enter your comment!
Please enter your name here