I have a document library in a SP 2013 site. I have a document content type with a document template associated to it. Now, I have written an
ItemUpdated event receiver which will update the document with some text (not the properties of the list item associated with the file for which I could use SystemUpdate method. So please keep this in mind, while providing the solution). Now, I go to the library, click on the files ribbon and then click New Document (not upload), this opens up my template and make some changes and save it (the document is open in my local machine). The event receiver fires, but when it tries to do
SPFiles.Add(with params, I tried both), it throws the error saying
The file 'fileUrl' is locked for shared use by "domainName\contributor1".
If, instead of saving the file, I close the file after making changes, this error doesn't occur. But I cannot control whether the user will save or close. I have not set the Require Checkout option also. Only versioning is turned on in the library. Also, I had turned on the DIP (Document Information Panel) display earlier, which I have now turned off. Even then, it is showing up.
Can anyone please help me with these issues?