I have a drop off library in a site collection on a SharePoint Online tenant and I am writing a C# console application to update properties of uploaded documents, my code doesn't seem to update the properties, can someone tell me what I am doing wrong or missing?
Please note, this is SharePoint Online tenant.
using (var context = new ClientContext(webUrl))
{
context.Credentials = new SharePointOnlineCredentials(cm.Username, password);
var web = context.Web;
// Get drop off library and edit all items without making changes
context.Load(web, w => w.Lists);
context.ExecuteQuery();
List dropOffLibrary = web.Lists.GetByTitle("Drop Off Library");
context.Load(dropOffLibrary, dl => dl.RootFolder.Files);
context.ExecuteQuery();
foreach (var file in dropOffLibrary.RootFolder.Files)
{
context.Load(file.ListItemAllFields);
context.ExecuteQuery();
file.CheckOut();
context.ExecuteQuery();
var title = file.ListItemAllFields.FieldValues["Title"].ToString();
file.ListItemAllFields.FieldValues["Title"] = title + "1";
file.Update();
context.Load(file);
context.ExecuteQuery();
file.CheckIn(string.Empty, CheckinType.OverwriteCheckIn);
context.ExecuteQuery();
}
context.Load(dropOffLibrary, dl => dl.RootFolder.Files);
context.ExecuteQuery();
Console.WriteLine("Paused... (end)");
Console.ReadLine();
}
}