AuthorizationRuleCollection
Represents a collection of AuthorizationRule objects.
Example
Check Deny Access File C#
public bool CheckDenyAccessFile(string filePath)
{
FileSecurity fs = File.GetAccessControl(filePath);
AuthorizationRuleCollection acl = fs.GetAccessRules(true, true, typeof(System.Security.Principal.SecurityIdentifier));
bool deny = false;
for (int x = 0; x < acl.Count; x++)
{
FileSystemAccessRule currentRule = (FileSystemAccessRule)acl[x];
AccessControlType accessType = currentRule.AccessControlType;
if (accessType == AccessControlType.Deny && (currentRule.FileSystemRights & FileSystemRights.ListDirectory) == FileSystemRights.ListDirectory)
{
deny = true;
break;
}
}
return deny;
}