如何检查';高级股';使用C#对文件夹的权限?

如何检查';高级股';使用C#对文件夹的权限?,c#,.net,directory,access-control,shared-directory,C#,.net,Directory,Access Control,Shared Directory,您好,我想检查是否与用户共享了特定文件夹。 对于普通股权,我可以通过 DirectoryInfo di = new DirectoryInfo(path); DirectorySecurity acl = di.GetAccessControl(AccessControlSections.All); AuthorizationRuleCollection rules = acl.GetAccessRules(true, true, typeof(NTAccount));

您好,我想检查是否与用户共享了特定文件夹。 对于普通股权,我可以通过

DirectoryInfo di = new DirectoryInfo(path);
    DirectorySecurity acl = di.GetAccessControl(AccessControlSections.All);
    AuthorizationRuleCollection rules = acl.GetAccessRules(true, true, typeof(NTAccount));

    //Go through the rules returned from the DirectorySecurity
    foreach (AuthorizationRule rule in rules)
    {
        //If we find one that matches the identity we are looking for
        if (rule.IdentityReference.Value.Equals(NtAccountName, StringComparison.CurrentCultureIgnoreCase))
        {
            //Cast to a FileSystemAccessRule to check for access rights
            if ((((FileSystemAccessRule)rule).FileSystemRights & FileSystemRights.WriteData) > 0)
            {
                Console.WriteLine(string.Format("{0} has write access to {1}", NtAccountName, path));
            }
            else
            {
                Console.WriteLine(string.Format("{0} does not have write access to {1}", NtAccountName, path));
            }
        }
    }
但这种方法的问题是,如果使用“高级共享”选项共享文件夹,如图所示,它不会显示日志中的任何条目

如何计算呢


最后,你得到答案了吗?我也需要这样做。