I'm currently writing C# code to automate doing a set of actions on a number of Excel files in a document library/folder tree. The actions include check out, running macros inside the Excel file, saving and checking the file back in, etc. I'd like to set the entire SharePoint document library as 'single user only' (i.e. the program) while operating to remove the possibility of outside changes during processing.

Is there any client based programmatic way to do this?


You can set the site collection to read-only, but that would prevent you from making your changes. By checking out the document, you will essentially put a lock on that file, isn't that good enough? Will your process update additional documents?

| improve this answer | |
  • Sorry it took so long to get back to you. Essentially I'm doing a user selected set of actions against a user selected list of files, and I want the actions to be atomic (i.e. either all selected files are acted against, or none are). – Falconeer Jul 16 '12 at 15:47
  • Then I would check out all of the affected documents at the start, and ensure that they are all checked in at the end. I would not change permissions on the objects. – Mike Oryszak Jul 16 '12 at 16:43

When your application starts processing, do the following changes to your document library programmatically.

  1. Add the people to a specific group say "Group1Readers" something like Visitor group (with a read-only permission level)
  2. Add the group to your document Library
  3. Use the Read Only permissions on the library
  4. Undo all Read only permissions on library, when processing is finished

All this can be achievable with the help of client-object model.

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.