查找文件的方法IO问题
DriveInfo[] allDrives = DriveInfo.GetDrives();
foreach (DriveInfo d in allDrives)
{
DirectoryInfo selDir = new DirectoryInfo(d.Name);
FileSystemInfo[] files = selDir.GetFileSystemInfos();
for (int i = 0; i < files.Length; i++)
{
if (files[i].Name == "Downloads")
{
DirectoryInfo bbbb = new DirectoryInfo(files[i].FullName);
FileSystemInfo[] filessss = bbbb.GetFileSystemInfos();
for (int j = 0; j < filessss.Length; j++)
{
if (filessss[j].Name == "CH_00")
{
DirectoryInfo ccc = new DirectoryInfo(filessss[j].FullName);
FileSystemInfo[] fileccc = ccc.GetFileSystemInfos();
for (int k = 0; k < fileccc.Length; k++)
{
DirectoryInfo ddd = new DirectoryInfo(fileccc[k].FullName);
FileSystemInfo[] fileddd = ddd.GetFileSystemInfos();
}
}
}
}
}
}
这段代码为什么老是报IO异常呢
还有这个这个方法可以简写吗?
------解决方案--------------------
------解决方案--------------------权限不足吧
------解决方案--------------------报错,你总要知道哪句报错吧,自己不会调试吗
------解决方案--------------------
你要获得磁盘下某些指定的系统文件吗?
http://www.cnblogs.com/yukaizhao/archive/2011/07/27/system-io-file.html
------解决方案--------------------先检查一下对目录是否有访问权限~
再设置断点调试一下看是哪一步出了异常~~
------解决方案--------------------