我正在使用此语句以递归方式查找所有文件:
fileNames = System.IO.Directory.GetFiles(path, "*.*",
System.IO.SearchOption.AllDirectories);
使用Windows XP Search Companion发现的文件总数远低于wehen。这不是由隐藏文件引起的,我查了一下。看起来GetFiles会跳过一些具有深嵌套级别的目录,但不会被Windows Search Companion跳过。GetFiles在命令提示符中计算与“dir / s”相同的文件数。有人有线索吗?
发布于 2019-03-26 08:37:21
Search Companion查看ZIP文件。你在目录树中有这些吗?
发布于 2019-03-26 09:44:07
你能否确认没有抛出异常?
try {
fileNames = System.IO.Directory.GetFiles(path, "*.*",
System.IO.SearchOption.AllDirectories);
} catch (System.IOPathTooLongException) {
System.Diagnostics.Debug.Fail("Some path is too long to be processed.");
}
https://stackoverflow.com/questions/-100001046
复制相似问题