为什么 FastDirectoryEnumerator 如此之快,但处理其异常却如此之慢?

问题描述

我遇到了一个问题,以下是检查存在的文件,但没有提醒我它跳过不存在的目录(源自根 _rootDirectory):

_matchingFiles = FastDirectoryEnumerator.GetFiles(_rootDirectory,_searchItem,SearchOption.AllDirectories);

但是当我执行以下操作来存储我正在监控但找不到的目录时,速度非常慢:

try
{
    _matchingFiles = FastDirectoryEnumerator.GetFiles(_rootDirectory,SearchOption.AllDirectories);
}
catch (Exception e)
{
    var noMatchesFoundString = new List<string>
        {
            "Root: " + "<" + _rootDirectory + ">,Search Item: " + _searchItem,"Could Not Be Found",_monitoringID
        };

    Console.WriteLine(String.Join(" - ",noMatchesFoundString));

    StaleItems.AddRowToTable(noMatchesFoundString);
}

是否有更好的方法来存储来自 FastDirectoryEnumerator 的未找到文件的异常?如果不打算快速处理此类行为,是否应该在 FastDirectoryEnumerator 之前使用另一种方法

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)