public static Boolean ReplaceFileSecurity(string File, IdentityReference[] Account, FileSystemRights Rights, AccessControlType ControlType, InheritanceFlags Inherit, PropagationFlags Propagation)
{
FileInfo fInfo = new FileInfo(File);
FileSecurity fSecurity = fInfo.GetAccessControl();
try
{
fSecurity.SetAccessRuleProtection(true, false);
foreach (IdentityReference account in Account)
{
fSecurity.ResetAccessRule(new FileSystemAccessRule(account, Rights, Inherit, Propagation, ControlType));
}
fInfo.SetAccessControl(fSecurity);
}
catch (Exception ex)
{
LibraryLogging.Error("unable to ReplaceFileSecurity for {0} error {1}", File, ex.Message);
return false;
}
return true;
}