SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
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? – SPArchaeologist 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!

share|improve this answer

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).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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