The FileSecurity class specifies the access rights for a system file and how access attempts are audited. This class represents access and audit rights as a set of rules. Each access rule is represented by a FileSystemAccessRule object, while each audit rule is represented by a FileSystemAuditRule object.
The FileSecurity class is an abstraction of the underlying Microsoft Windows file security system. In this system, each file has a discretionary access control list (DACL), which controls access to the file, and a system access control list (SACL), which specifies the access control attempts that are audited. The FileSystemAccessRule and FileSystemAuditRule classes are abstractions of the access control entries (ACEs) that comprise DACLs and SACLs.
The FileSecurity class hides many of the details of DACLs and SACLs; you do not have to worry about ACE ordering or null DACLS.
Use the FileSecurity class to retrieve, add, or change the access rules that represent the DACL and SACL of a file.
To persist new or changed access or audit rules to a file, use the SetAccessControl method. To retrieve access or audit rules from an existing file, use the GetAccessControl method.