In document library, I've some documents with version history. In C#, can I get all the version history of document and update the user?

The version history of a document is like below:

Data                Modified By

doc1 changed        User X
some text           User X

Now in C# can I update the Modified By user value with another user?

Thanks in advance

  • Just to confirm. You want to change the modified by attribute on all the version of the item so after the update even the old version will show the edited "modified by" user? – SPArcheon Oct 22 '12 at 6:46
SPSite site = new SPSite("http://sharepointsite/subsite");
SPWeb web = site.OpenWeb();
SPList list = web.Lists["My List"];
web.AllowUnsafeUpdates = true;
foreach (SPListItem item in list.Items)
  item["Modified"] = "Set the date";
  item["Created"] = "Set the date";

Hope this helps!


If you call SPListItem.Update() in code I believe that changes the Modified By value to whichever user triggered the code (while SystemUpdate() does not).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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