RecursivelyPermissionEditor/RecursivelyPermissionEditor.cs
/// <summary>
/// Removes an ACL entry on the specified file for the specified account.
/// </summary>
/// <param name="fileName">The name of the file needed to be modified.</param>
/// <param name="account">This parameter delcares which user that the rights belong to.</param>
/// <param name="rights">Thr rights to be added or removed.</param>
/// <param name="controlType">The type of the access control.</param>
Removes an ACL entry on the specified file for the specified account.
Removes an ACL entry on the specified file for the specified account .
public static void ModifySecurity(Type type, string fileName, string account,
            FileSystemRights rights, AccessControlType controlType, Mode mode)
        {
            FileSystemSecurity Security;
            if (Type.FILE == type)
                Security = File.GetAccessControl(fileName);
            else
                Security = Directory.GetAccessControl(fileName);
            if (Mode.ADD == mode)
                Security.AddAccessRule(new FileSystemAccessRule(account, rights, controlType));
            else
                Security.RemoveAccessRule(new FileSystemAccessRule(account, rights, controlType));
            if (Type.FILE == type)
                File.SetAccessControl(fileName, Security as FileSecurity);
            else
                Directory.SetAccessControl(fileName, Security as DirectorySecurity);
        }
public static void ModifySecurity ( Type type , string fileName , string account , FileSystemRights rights , AccessControlType controlType , Mode mode ) { FileSystemSecurity Security ; if ( Type . FILE == type ) Security = File . GetAccessControl ( fileName ) ; else Security = Directory . GetAccessControl ( fileName ) ; if ( Mode . ADD == mode ) Security . AddAccessRule ( new FileSystemAccessRule ( account , rights , controlType ) ) ; else Security . RemoveAccessRule ( new FileSystemAccessRule ( account , rights , controlType ) ) ; if ( Type . FILE == type ) File . SetAccessControl ( fileName , Security as FileSecurity ) ; else Directory . SetAccessControl ( fileName , Security as DirectorySecurity ) ; }
Removes an ACL entry on the specified file for the specified account.
Removes an ACL entry on the specified file for the specified account .
// Get a FileSecurity object that represents the // current security settings. // Remove the FileSystemAccessRule from the security settings. // Set the new access settings.
type
Type
fileName
string
The name of the file needed to be modified.
The name of the file needed to be modified .
account
string
This parameter delcares which user that the rights belong to.
This parameter delcares which user that the rights belong to .
rights
FileSystemRights
Thr rights to be added or removed.
Thr rights to be added or removed .
controlType
AccessControlType
The type of the access control.
The type of the access control .
mode
Mode