我的应用程序中有 4 个文件夹,每个文件夹都有一定的权限...
文件夹1里面有文件夹2,文件夹2里面有文件夹3和文件夹4
我可以使用以下代码拒绝从文件夹 2 到文件夹 3 的继承,但我想从文件夹 1 继承到文件夹 3?
我希望文件夹继承 folder1 的所有属性
string folderpath="xyz";
string UserAccount = "asp";
System.IO.DirectoryInfo FolderInfo = new System.IO.DirectoryInfo(folderpath);
DirectorySecurity FolderAcl = new DirectorySecurity();
FolderAcl.AddAccessRule(new FileSystemAccessRule(UserAccount, FileSystemRights.ReadData, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow));
const bool protectRulesFromInheritance = true;
const bool preserveInheritance = true;
FolderAcl.SetAccessRuleProtection(protectRulesFromInheritance, preserveInheritance);
FolderInfo.SetAccessControl(FolderAcl);