【发布时间】:2015-05-19 12:25:41
【问题描述】:
private int GetFileCount(DirectoryInfo directory)
{
int retVal = directory.GetFiles().Length;
try
{
Array.ForEach(directory.GetDirectories(), dir =>
{
retVal += GetFileCount(dir);
});
}
catch (UnauthorizedAccessException ex)
{
//Here stops the execution
}
return retVal;
}
当我扫描任何磁盘驱动器时,我已经编写了上面的代码...给了我访问被拒绝的异常..来处理异常写入的 catch 块,但它会停止进一步的迭代..应该如何继续进一步的迭代
【问题讨论】: