I know this question has been asked in the past, but I can't seem to find a working solution. I want to update The CreatedDateTime, ModifiedBy and CreatedBy metadata on a file that I uploaded with CSOM. I have this code. It does not crash, but does not update the properties either.

        FileCreationInformation newFile = new FileCreationInformation();
        byte[] FileContent = null;
        using (var webClient = new WebClient())
            webClient.Headers.Add("Authorization", authorization);
            FileContent = webClient.DownloadData(file.DowlnloadUrl);

        newFile.ContentStream = new System.IO.MemoryStream(FileContent);
        newFile.Url = System.IO.Path.GetFileName(file.Name);
        Microsoft.SharePoint.Client.File sharepointFile = _spFolder.Files.Add(newFile);

        sharepointFile.ListItemAllFields["Modified"] = DateTime.Today.AddDays(-3);
        sharepointFile.ListItemAllFields["Created"] = DateTime.Today.AddDays(-3);

The file still appears that it was created/modified a few seconds ago.

enter image description here

Any help would be appreciated. PS: if this can be done in one go (one single ExecuteQuery), that would be great.

  • Have you tried to update other fields like title? Will it work? Commented Sep 8, 2021 at 8:40
  • @MichaelHan_MSFT Yes, it seems to work with Title, but it creates a new version where the Title appears. I tried adding disabling the versioning and updating the Dates, but still no luck.
    – Rafa Ayadi
    Commented Sep 8, 2021 at 11:10
  • Ok you could try to set the Modified field property ReadOnlyField to false, then updating the dates. Commented Sep 9, 2021 at 9:36
  • That did not help either.
    – Rafa Ayadi
    Commented Sep 9, 2021 at 22:26

2 Answers 2


Try this:


ListItem item = uploadFile.ListItemAllFields;
item["FieldName"] = "SomeFieldValue";

// use OverwriteCheckIn type to make sure not to create multiple versions 
uploadFile.CheckIn(string.Empty, CheckinType.OverwriteCheckIn);

See reference: update document properties in library using csom

or check


  • Hi Martin. I have seen this thread and it is still not working in my case. It is very odd. I have tried multiple solutions on stackoverflow yet nothing worked for me. (Tried disabling and enabling Versionning, and it did not work either).
    – Rafa Ayadi
    Commented Sep 7, 2021 at 21:27

This was very tricky. My app is running on .NetCore 3.1. Below is the endpoint I am using to generate a Token and then a ClientContext

            var body = $"resource={resource}&client_id={_clientId}&grant_type=password&username={HttpUtility.UrlEncode(_userName)}&password={HttpUtility.UrlEncode(pwd)}";

The clientId is my Azure App Client Id. This code generates a Bearer token. When you decode the token, you can see the permissions you have with it. I needed the SitesFullControl delegated permission. enter image description here

Once I added that permission, my Bearer token decode had it and my Update ModifiedDate worked. I hope this can help anyone who spent days trying to figure this out like I did.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.