I have downloaded a document file (current version) and its version history files (old version files) from one of my sharepoint site list. Now, I want to upload that current version file into another site list. After uploading the current version file, I need to upload its version files into _vti_history folder and update version information in current version file.
I can upload the current version file by using below csom code:
using (var clientContext = new ClientContext(url))
{
using (var fs = new FileStream(fileName, FileMode.Open))
{
var fi = new FileInfo(fileName);
var list = clientContext.Web.Lists.GetByTitle(listTitle);
clientContext.Load(list.RootFolder);
clientContext.ExecuteQuery();
var fileUrl = String.Format("{0}/{1}", list.RootFolder.ServerRelativeUrl, fi.Name);
Microsoft.SharePoint.Client.File.SaveBinaryDirect(clientContext, fileUrl, fs, true);
}
}
But, I don't know how to upload the version file and update version info in actual file.
Can anyone help me to achieve this in C# using csom?