Created
August 12, 2018 09:59
-
-
Save AsishP/97c139994b78cdfd670fdd7dcb34680f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (Context ctx = new ClientContext(<siteUrl>)) | |
{ | |
string TemplateFilename = "<FileName>.xml"; | |
ctx.Load(ctx.Web, w => w.Lists, w => w.Folders); | |
Microsoft.SharePoint.Client.File templateFile = ctx.Web.Lists.GetByTitle("Site Assets").RootFolder.Folders.GetByUrl("Templates").GetFile(TemplateFilename); | |
ctx.ExecuteQuery(); | |
FileInformation fileInfo = Microsoft.SharePoint.Client.File.OpenBinaryDirect(ctx, templateFile.ServerRelativeUrl); | |
assetContext.ExecuteQuery(); | |
filePath = Path.GetTempPath() + "\\" + TemplateFilename; | |
using (var fileStream = new FileStream(filePath, FileMode.Create)) | |
fileInfo.Stream.CopyTo(fileStream); | |
} | |
using (FileStream fs = System.IO.File.OpenRead(filePath)) | |
{ | |
ITemplateFormatter formatter = XMLPnPSchemaFormatter.LatestFormatter; //Use the same version as the PnP template | |
Template = formatter.ToProvisioningTemplate(fs); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment