DirectoryInfo dir = New DirectoryInfo ();
     dir.GetFiles();  我这是获取目录下的所有文件,但在每个磁盘下都有System Volume Information 系统文件,所有没有权限访问!
  一调试就报错 “对路径“E:\System Volume Information”的访问被拒绝 ” 
  我想的是怎样屏蔽后缀名为.sys的文件  

解决方案 »

  1.   

    System Volume Information这个文件夹是放系统还原的一些文件的,你要添加权限的
      

  2.   

    private static bool IsSystemHidden(DirectoryInfo dirInfo)
            {
                if (dirInfo.Parent == null)
                {
                    return false;
                }
                string attributes = dirInfo.Attributes.ToString();
                if (attributes.IndexOf("Hidden") > -1 && attributes.IndexOf("System") > -1)
                {
                    return true;
                }
                return false;
            }
      

  3.   


     我知道可以修改文件的访问权限,但我不想修改文件的访问权限,我是想在遍历目录里的文件的时候,有.sys
     后缀名的文件就不执行操作!