Search code examples
c#.netsecuritypermissions

Remove All Directory Permissions


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.


Solution

  • 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 :-)