Applies access control list (ACL) entries described by a FileSecurity object to the specified file.
Assembly: mscorlib (in mscorlib.dll)
An I/O error occurred while opening the file.
The path parameter is a null reference (Nothing in Visual Basic).
The file could not be found.
The path parameter specified a file that is read-only.
This operation is not supported on the current platform.
The path parameter specified a directory.
The caller does not have the required permission.
The fileSecurity parameter is a null reference (Nothing in Visual Basic).
The method applies access control list (ACL) entries to a file that represents the noninherited ACL list.
The ACL specified for the fileSecurity parameter replaces the existing ACL for the file. To add permissions for a new user, use the GetAccessControl method to obtain the existing ACL, modify it, and then use to apply it back to the file.
An ACL describes individuals and/or groups who have, or do not have, rights to specific actions on the given file. For more information, see ACL Technology Overview and How to: Add or Remove Access Control List Entries.
The method persists only FileSecurity objects that have been modified after object creation. If a FileSecurity object has not been modified, it will not be persisted to a file. Therefore, it is not possible to retrieve a FileSecurity object from one file and reapply the same object to another file.
To copy ACL information from one file to another:
Create a new FileSecurity object for the destination file.
Set the destination FileSecurity object to the destination file using the method.
In NTFS environments, ReadAttributes and ReadExtendedAttributes are granted to the user if the user has ListDirectory rights on the parent folder. To deny ReadAttributes and ReadExtendedAttributes, deny ListDirectory on the parent directory.