How to establish full control over the directory

I use the following code to establish full control

DirectorySecurity myDirectorySecurity = source.GetAccessControl(); string User = "Srinivass\\Admin"; myDirectorySecurity.AddAccessRule(new FileSystemAccessRule( User, FileSystemRights.Modify, InheritanceFlags.ObjectInherit, PropagationFlags.InheritOnly, AccessControlType.Allow) ); source.SetAccessControl(myDirectorySecurity); 

But it grants special permissions only to this folder. I want to provide full permissions for all subfolders.

Please someone can help me.

+7
source share
1 answer

Try changing the PropagationFlags parameter to PropagationFlags.None .

Your access rule should look like this:

  new FileSystemAccessRule( User, FileSystemRights.FullControl, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow ); 

Then check the Security tab in Windows Explorer and you will see a folder (and any newly created objects in the future) with Full Control .

+15
source

All Articles