I am using the following code to set 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 is giving special permissions to this folder only. I want to give full controll permissions to all subfolders.
Please anyone can help me.
Changing permissions with chmod To modify the permission flags on existing files and directories, use the chmod command ("change mode"). It can be used for individual files or it can be run recursively with the -R option to change permissions for all of the subdirectories and files within a directory.
You can set permissions like read, write, or execute the folder through the “chmod” command in a terminal. You can use the “chmod” command to modify permission settings in two different ways: Absolute Mode (numeric mode) Symbolic Mode.
Try changing PropagationFlags
parameter to PropagationFlags.None
.
Your access rule should look like:
new FileSystemAccessRule(
User,
FileSystemRights.FullControl,
InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
PropagationFlags.None,
AccessControlType.Allow
);
Then, check the Security tab in Windows Explorer, and you should see the folder (and any newly created objects going forward) having Full Control.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With