I have a problem to replicate my wiki pages from one SharePoint site to another one. I am using CSOM (Client Side Object Model) and the following (simplified) code :
var fileCreationInformation = new SP.FileCreationInformation();
string page = EXTRACTED VALUE OF THE SOURCE FIELD "wikiField" (string)
byte[] bytes = new byte[page.Length * sizeof(char)];
System.Buffer.BlockCopy(page.ToCharArray(), 0, bytes, 0, bytes.Length);
fileCreationInformation.Content = bytes;
fileCreationInformation.Overwrite = true;
fileCreationInformation.Url = EXTRACTED VALUE OF THE SOURCE FIELD "FileLeafRef" (string)
Microsoft.SharePoint.Client.File uploadFile = oList.RootFolder.Files.Add(fileCreationInformation);
clientContext.Load(uploadFile);
clientContext.ExecuteQuery();
My problem is after the copy, my new wiki pages are created and the content is perfectly displayed except that there is no Quicklaunch and Ribbon. It is just my raw content (e.g. XML only for xml page) which is displayed and it is kind of ugly 🙂
Do you have an idea how can I fix this issue? Do I miss something or I attack the problem in a wrong way?
Thank you in advance!
Nicolas
Thank you Josh, it was the good idea. I fixed my problem by using the AddTemplateFile!
Here is the (simplified) code :