Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

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?

share|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
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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