编程删除"包括可从该对象的父&QUOT的可继承权限;使用C#复选框
问题描述:
我有一个要求,在我的应用程序遍历所有子文件夹
编程删除包括可从该对象的父项继承的权限复选框,使用C#。
I have a requirement in my application to iterate through all the sub-folders programatically removing "Include inheritable permissions from this object's parent" check box using C#.
和也转换并添加继承父权限在文件夹上明确权限。
And also convert and add the inherited parent permissions as explicit permissions on the folder.
任何一个可以让我知道?我怎么能做到这一点在C#。
Can any one let me know ? how can i do it in C#.
答
您需要使用 ObjectSecurity.SetAccessRuleProtection :
You need to use ObjectSecurity.SetAccessRuleProtection:
string path = @"...";
FileSecurity fs = File.GetAccessControl(path);
fs.SetAccessRuleProtection(true, false);
File.SetAccessControl(path, fs);