programatically removing "Include inheritable permissions from this object's parent" checkbox using 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.
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);
精彩评论