Question

As you can see here, rename event of list item via Windows Explorer is handler by ItemFileMoved event.

So, I was trying to prevent this edit by the usual way of preventing ItemUpdating:

properties.Cancel = true;
properties.ErrorMessage = "You cannot edit."; 

While it works in the ItemUpdating event when trying to rename an item from SharePoint UI, it doesn't cancel the rename event from Windows Explorer.

Is there any other way of doing this?

And I don't mean disabling the whole possibility of opening the library with Explorer, it would be an overkill.

Was it helpful?

Solution

Turned out I've handled the operation a little too late because it works only when handling the event ItemFileMoving not ItemFileMoved.

It's as simple as that:

properties.Cancel = true;

because the ErrorMessage won't be displayed in Explorer.

The default Windows error message looks like this: enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top