C#AddAccessRule用于“此文件夹,子文件夹和文件”

时间:2017-03-15 12:51:47

标签: c# asp.net access-rules

我有一些代码将权限应用于有效的文件夹,但它将文件夹权限设置为“特殊”,并将其应用为“此文件夹和文件”,我需要将其应用为“此文件夹,子文件夹和文件”。我做错了什么?

dSecurity.AddAccessRule(new FileSystemAccessRule(@"DOMAIN\" + Account, FileSystemRights.ReadAndExecute, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.InheritOnly, ControlType));

1 个答案:

答案 0 :(得分:1)

尝试将其分为两个规则;

dSecurity.AddAccessRule(new FileSystemAccessRule(@"DOMAIN\" + Account, FileSystemRights.ReadAndExecute, InheritanceFlags.ContainerInherit, PropagationFlags.InheritOnly, ControlType));
dSecurity.AddAccessRule(new FileSystemAccessRule(@"DOMAIN\" + Account, FileSystemRights.ReadAndExecute, InheritanceFlags.ObjectInherit, PropagationFlags.InheritOnly, ControlType));