Abstractions.Windows.Security.SetDirectorySecurity C# (CSharp) Method

SetDirectorySecurity() public static method

public static SetDirectorySecurity ( string dir, IdentityReference Account, FileSystemRights Rights, AccessControlType ControlType, InheritanceFlags Inherit, PropagationFlags Propagation ) : System.Boolean
dir string
Account System.Security.Principal.IdentityReference
Rights FileSystemRights
ControlType AccessControlType
Inherit InheritanceFlags
Propagation PropagationFlags
return System.Boolean
        public static Boolean SetDirectorySecurity(string dir, IdentityReference[] Account, FileSystemRights Rights, AccessControlType ControlType, InheritanceFlags Inherit, PropagationFlags Propagation)
        {
            DirectoryInfo dInfo = new DirectoryInfo(dir);
            DirectorySecurity dSecurity = dInfo.GetAccessControl();

            try
            {
                foreach (IdentityReference account in Account)
                {
                    dSecurity.AddAccessRule(new FileSystemAccessRule(account, Rights, Inherit, Propagation, ControlType));
                }
                dInfo.SetAccessControl(dSecurity);
            }
            catch (Exception ex)
            {
                LibraryLogging.Error("unable to SetDirectorySecurity for {0} error {1}", dir, ex.Message);
                return false;
            }

            return true;
        }

Same methods

Security::SetDirectorySecurity ( string dir, string Account, FileSystemRights Rights, AccessControlType ControlType, InheritanceFlags Inherit, PropagationFlags Propagation ) : System.Boolean