There is a method that for a given folder returns user rights. It is not entirely clear how to get these very rights out of there. In the debugger, I see the whole property, but when I assign it to a variable, then there is only one “right”, and that is the first thing. ToString() did the same thing. How to get this array *? However, Console.WriteLine displays this info without any problems.

 void FindInheritedFrom(FileSystemAccessRule rule, string path) { var security = File.GetAccessControl(path); var accessRules = security.GetAccessRules(true, true, typeof(NTAccount)); var matching = accessRules.OfType<FileSystemAccessRule>() .FirstOrDefault(r => r.AccessControlType == rule.AccessControlType && r.FileSystemRights == rule.FileSystemRights && r.IdentityReference == rule.IdentityReference); if (matching != null) { if (matching.IsInherited) FindInheritedFrom(rule, Directory.GetParent(path).FullName); else { dic.Add(rule.IdentityReference.ToString(), rule.FileSystemRights.ToString().Split('|').ToList()); } } } 

enter image description here

    1 answer 1

    Try this:

      dic.Add(rule.IdentityReference.ToString(), rule.FileSystemRights.ToString().Split(',').ToList()); 

    PS: rule.FileSystemRights.ToString () returns a string of rights separated by commas, not '|'.