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

I am trying to update a document in the item updating event receiver, but I keep getting the error: "The file IOF/This is a.docx has been modified by ....."

I have the following code in my SP 2013 environment in an event receiver:

public override void ItemUpdating(SPItemEventProperties properties)
        EventFiringEnabled = false;
        properties.List.ParentWeb.AllowUnsafeUpdates = true;

        SPListItem item = GetListItem (properties.ListItem);
        SPFile file = item.File;

        if ((SPFileLevel) Convert.ToInt32( properties.AfterProperties["vti_level"]) == SPFileLevel.Published)
            //Update the published date inside the document
            byte[] contents = file.OpenBinary();
            ISPWorker worker = Worker.GetWorker(file.Name, contents);


        properties.List.ParentWeb.AllowUnsafeUpdates = false;
        EventFiringEnabled = true;

share|improve this question
Try the same in ItemUpdated event instead of Updating ! – Arsalan Adam Khatri Apr 1 '13 at 13:21
I cant use ItemUpdated because by then its check in already and when I edit the document I get an error that the document must first be checked out. – NYTom Apr 1 '13 at 13:21
You can checkout/checkin inside your event receiver – lgaud Apr 1 '13 at 15:08
I thought about that but that would mean for every check in the major version would go up by two since Im dealing with published documents. – NYTom Apr 1 '13 at 17:21
I tried checking out the file, updating it and then checking it back in in the ItemAdded event but I get the same error. – NYTom Apr 1 '13 at 17:59

Your Answer


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

Browse other questions tagged or ask your own question.