/// <summary>
        /// 判断指定的文件或目录是否拥有与 identity 相关联的权限设置。
        /// </summary>
        /// <param name="path">文件或目录路径。</param>
        /// <param name="identity">Windows 用户或组名称。</param>
        /// <returns>存在返回 true;否则返回 false。</returns>
        public static bool IsExistsPermission(string path, string identity)
        {
            identity = identity.ToLower();
            bool hasDomain = (identity.IndexOf('\\') != -1);

            if (System.IO.Directory.Exists(path))
            {
                System.Security.AccessControl.DirectorySecurity           ds  = System.IO.Directory.GetAccessControl(path);
                System.Security.AccessControl.AuthorizationRuleCollection arc = ds.GetAccessRules(true, true, typeof(System.Security.Principal.NTAccount));
                foreach (System.Security.AccessControl.FileSystemAccessRule tmp in arc)
                {
                    string ident = tmp.IdentityReference.Value.ToLower();
                    if (hasDomain)
                    {
                        if (ident == identity)
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        if (ident == identity || ident.EndsWith(@"\" + identity))
                        {
                            return(true);
                        }
                    }
                }
            }
            else if (System.IO.File.Exists(path))
            {
                System.Security.AccessControl.FileSecurity ds = System.IO.File.GetAccessControl(path);
                System.Security.AccessControl.AuthorizationRuleCollection arc = ds.GetAccessRules(true, true, typeof(System.Security.Principal.NTAccount));
                foreach (System.Security.AccessControl.FileSystemAccessRule tmp in arc)
                {
                    string ident = tmp.IdentityReference.Value.ToLower();
                    if (hasDomain)
                    {
                        if (ident == identity)
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        if (ident == identity || ident.EndsWith(@"\" + identity))
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
        /// <summary>
        /// 获取权限集合。
        /// </summary>
        /// <param name="path">文件或目录路径。</param>
        /// <returns>权限集合。</returns>
        public static string[] GetPermissions(string path)
        {
            System.Collections.Generic.List <string> l = new System.Collections.Generic.List <string>();

            if (System.IO.Directory.Exists(path))
            {
                System.Security.AccessControl.DirectorySecurity           ds  = System.IO.Directory.GetAccessControl(path);
                System.Security.AccessControl.AuthorizationRuleCollection arc = ds.GetAccessRules(true, true, typeof(System.Security.Principal.NTAccount));
                foreach (System.Security.AccessControl.FileSystemAccessRule tmp in arc)
                {
                    l.Add(tmp.IdentityReference.Value);
                }
            }
            else if (System.IO.File.Exists(path))
            {
                System.Security.AccessControl.FileSecurity ds = System.IO.File.GetAccessControl(path);
                System.Security.AccessControl.AuthorizationRuleCollection arc = ds.GetAccessRules(true, true, typeof(System.Security.Principal.NTAccount));
                foreach (System.Security.AccessControl.FileSystemAccessRule tmp in arc)
                {
                    l.Add(tmp.IdentityReference.Value);
                }
            }
            return(l.ToArray());
        }