using System; using System.IO; namespace FileDemo { class Program { static void Main(string[] args) { FileInfo fileInfo = new FileInfo(@"C:\Temp\MyFile.txt"); FileSecurity fileSecurity = fileInfo.GetAccessControl(); AuthorizationRuleCollection accessRules = fileSecurity.GetAccessRules(true, true, typeof(System.Security.Principal.NTAccount)); Console.WriteLine("Access Rules for {0}:", fileInfo.Name); foreach (FileSystemAccessRule accessRule in accessRules) { Console.WriteLine("{0} {1} {2}", accessRule.IdentityReference, accessRule.AccessControlType, accessRule.FileSystemRights); } } } }In this example, we first create a new FileInfo object for the file "C:\Temp\MyFile.txt". We then call the GetAccessControl method on the FileInfo object to get the security descriptor for the file. We then use the GetAccessRules method on the FileSystemSecurity object to get a collection of the access rules for the file. We then loop through each access rule in the collection and display the identity reference, access control type, and file system rights for each rule. The System.IO package library provides many more classes and methods for working with files and directories, including reading and writing file contents, creating and deleting directories, and setting file attributes. The FileInfo class is just one of many useful classes in this package library.