开发者

programatically removing "Include inheritable permissions from this object's parent" checkbox using C#

开发者 https://www.devze.com 2023-03-17 00:40 出处:网络
I have a requirement in my application to iterate through all the开发者_如何转开发 sub-folders

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#.

programatically removing "Include inheritable permissions from this object's parent" checkbox using C#

And also convert and add the inherited parent permissions as explicit permissions on the folder.

Can any one let me know ? how can i do it in C#.


You need to use ObjectSecurity.SetAccessRuleProtection:

string path = @"...";
FileSecurity fs = File.GetAccessControl(path);
fs.SetAccessRuleProtection(true, false);
File.SetAccessControl(path, fs);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号