且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何设置文件夹的权限

更新时间:2022-11-28 11:34:18

如果通过继承你的意思是所有子对象收到相同的权限,您需要将您的PropagationFlags设置为InheritOnly。另外,如果你想你的文件是为了匹配规则集的权限,更改为InheritanceFlags ObjectInherit。尝试使用下面这条线。

If by inherited you mean that all child objects receive the same permissions, you will need to set your PropagationFlags to InheritOnly. Further if you want your files to also match the permission of the ruleset, change your InheritanceFlags to ObjectInherit. try using this line below.

myDirectoryInfo.AddAccessRule(new FileSystemAccessRule(User, FileSystemRights.FullControl, InheritanceFlags.ObjectInherit, PropagationFlags.InheritOnly, AccessControlType.Allow));