views:

438

answers:

3

In C# (2.0) How do I remove all permissions to a directory, so I can limit the access. I will be adding access back to a limited set of users.

A: 

Here is a great set of articles from CodeProject about Windows ACL programming:

The Windows Access Control Model

Part 3 of the series shows .NET specific methods.

Dana Holt
A: 

System.IO.Directory.GetAccessControl() and then edit the returned FileSecurity object.

codymanix
Directory budy.
C. Ross
nearly the same ^^ I changed it now.
codymanix
+4  A: 

Look at the classes in the System.Security.AccessControl namespace, and especially the DirectorySecurity.RemoveAccessRule method.

Also, if you remove all the permissions then you won't be able to add any back afterwards :-)

Stu Mackellar