C# Show a File’s DACL Entries
Listing 1. The file’s method loops through the access control entries that are associated with the file, and then displays the ACEs on the screen with the help of the custom ShowRightsForm dialog box. private void ShowFileRights(string filename) { FileSecurity fileSec = System.IO.File.GetAccessControl(filename); System.Type wantedType = typeof( System.Security.Principal.NTAccount); if (showFileSIDsCheckBox.Checked) { wantedType = typeof( System.Security.Principal.SecurityIdentifier); } AuthorizationRuleCollection rules = fileSec.GetAccessRules(true, showInheritedFileRightsCheckBox.Checked, wantedType); // loop through all the rules the object has List |