0

I can search folder permissions using cacls.exe with command prompt and output them to a text file but I need to display the folder permissions within the C# program so that i can use them in strings etc.

Chris
  • 1
  • 2
  • 1
    [Similar](http://stackoverflow.com/questions/1410127/c-sharp-test-if-user-has-write-access-to-a-folder?noredirect=1&lq=1) thread posted before, it may help. – Ahmed I. Elsayed Sep 08 '16 at 03:50

1 Answers1

1
DirectorySecurity dSecurity = Directory.GetAccessControl(@"d:\myfolder");
foreach (FileSystemAccessRule rule in dSecurity.GetAccessRules(true, true, typeof(NTAccount)))
{
    if (rule.FileSystemRights == FileSystemRights.Read)
    {
        Console.WriteLine("Account:{0}", rule.IdentityReference.Value);
    }
}
enginne
  • 11
  • 4