I am working in SP 2013 On-premise. I am trying to re-upload documents from a folder in my local machine to my document Library. The code works fine. However, on downloading the document, I see no change in the document content even though the version gets updated (this maybe because I am also updating a field).
I am using CSOM SaveBinaryDirect method. This is my code :
FileStream stream = new FileStream(filename, FileMode.Open);
Microsoft.SharePoint.Client.File.SaveBinaryDirect(context, path, stream, true);
var uploadedfile = context.Web.GetFileByServerRelativeUrl(path);
context.Load(uploadedfile);
context.ExecuteQuery();
if(uploadedfile.CheckOutType == CheckOutType.None)
{
uploadedfile.CheckOut();
}
context.ExecuteQuery();
var listitem = uploadedfile.ListItemAllFields;
listitem["column"] = "Value";
listitem.Update();
context.ExecuteQuery();
listitem.File.CheckIn("", CheckinType.MajorCheckIn);
context.ExecuteQuery();
Any help would be appreciated!