I am using CSOM to create folders and upload files on a Sharepoint 2013 document Library. I am creating folders and subfolders inside them by calling the code below in a loop and trying to set their Property values as shown :

if(!site.DefaultLibrary.RootFolder.Folders.Any(p=>p.Name == "Folder Name"))                

var folder = site.DefaultLibrary.RootFolder.Folders.Add("Folder Name");

site.DefaultContext.Load(folder, p => p.Properties);

folder.Properties["Some Property Key"] = "Some Property Value" ;                           



For multiple synchronous client requests calling this method this code works fine . However , when making multiple asynchronous client calls this code fails on line 04 with the following message:

The file "Library Name"/"Folder Name" has been modified by (unknown) on .....

What was further observed was that this issue was only observed in the following scenario:

Trying to create the following folders/subfolders inside "Test Library"

"Test Library"/"XXXX"/"XXX1234"

"Test Library"/"XXXX"/"XXX5678"

"Test Library"/"XXXX"/"XXX1212"

Which suggests that if I try to create multiple sub folders inside the same root folder(in this case XXXX asynchronously then it fails.However if the root folder is different then this issue does not happen).

There are also Event receivers on the server for handling item updated/updating events when they are triggered from the client.

However I assume that the issue is somewhere in the client code which should be optimized.

Any suggestions on this would be very helpful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.