DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
How To Check File Permissions In C#
Use following snippet to find a file's associated DACL (Discretionary Access control List)
ArrayList fileACL = new ArrayList();
FileSecurity fileSecurity = new FileSecurity(@"C:\Windows\system.ini", AccessControlSections.Access);
AuthorizationRuleCollection arc = fileSecurity.GetAccessRules(true, true, typeof(NTAccount));
foreach (FileSystemAccessRule rule in arc)
{
fileACL.Add(rule.IdentityReference + ":" + rule.AccessControlType + " " + rule.FileSystemRights.ToString());
}





