日期:2014-05-17  浏览次数:20533 次

C# 判断文件夹是否可写
如题!不通过抛出异常的方式,有没有直接获取文件夹此属性的方法。

------解决方案--------------------
  //
        // 摘要:
        //     获取 System.Security.AccessControl.DirectorySecurity 对象,该对象封装当前 System.IO.DirectoryInfo
        //     对象所描述的目录的访问控制列表 (ACL) 项。
        //
        // 返回结果:
        //     一个 System.Security.AccessControl.DirectorySecurity 对象,该对象封装此目录的访问控制规则。
        //
        // 异常:
        //   System.SystemException:
        //     未能找到或修改该目录。
        //
        //   System.UnauthorizedAccessException:
        //     当前进程不具有打开该目录的权限。
        //
        //   System.IO.IOException:
        //     打开目录时发生 I/O 错误。
        //
        //   System.PlatformNotSupportedException:
        //     当前操作系统不是 Microsoft Windows 2000 或更高版本。
        //
        //   System.UnauthorizedAccessException:
        //     目录为只读。- 或 - 在当前平台上不支持此操作。- 或 - 调用方没有所要求的权限。
        public DirectorySecurity GetAccessControl();

------解决方案--------------------

   private static  List<FileSystemRights> GetQuanXian()