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.In开发者_运维技巧heritOnly,
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.
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.
精彩评论