I have a document library. In ItemUpdated I move the file to a different location (based on date) and I want to add some metadata in ItemFileMoved to the file's new columns (which I added). The problem is I receive an error related to ItemFileMoved:

<nativehr>0x81020015</nativehr><nativestack></nativestack>The file file/path has been modified by Domain/User on 04 Jan 2013 10:36:02 +0100.

This is my code in ItemFileMoved:

SPListItem movedFile = properties.ListItem;
// some changes to my columns

I'm not sure what I am doing wrong. My questions are: 1) Is the problem in the way I get the item? How can I get an SPListItem for a file if not using properties.ListItem? 2) Is it better to modify files metadata in ItemUpdated before I use file.MoveTo?

Thank you in advance for any help.

1 Answer 1


I have not personally run into this issue but it sounds a lot like an unsafe update error. Assuming properties.ListItem is a reference to the newly moved file and not null or somehow have a reference to the old file location, you can try something like this:

movedFile.Web.AllowUnsafeUpdates = true;
movedFile.Web.AllowUnsafeUpdates = false;

Another theory you can play with - I've also seen some interesting behavior with events that depends on base.Event(properties) and where it is in the code. This was a long time ago so I don't remember specifics on what worked for me or what issue I was having, but you could try moving it to the end instead of the beginning of your method call, or removing it altogether and see what happens.

Hopefully something here can help you out.

  • Thanks, it works. I only get new errors when creating new folders, but I suppose it's a new issue :-) Jan 7, 2013 at 12:36

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.