我需要获取文件夹中子文件夹的所有路径(使用 WinAPI 和 C++。)到目前为止,我找到的唯一解决方案是递归调用 FindFirstFile/FindNextFile但是在具有更深层次结构的文件夹上执行此操作需要花费大量时间。
所以我想知道,只是为了获取文件夹名称,是否有更快的方法?
最佳答案
如果你真的只需要子文件夹,你应该能够使用 FindFirstFileEx
search options过滤掉非目录。
文档建议这只是一个建议标志,但您的文件系统可能支持此优化 - 试一试。
FindExSearchLimitToDirectories
This is an advisory flag. If the file system supports directory filtering, the function searches for a file that matches the specified name and is also a directory. If the file system does not support directory filtering, this flag is silently ignored.
关于c++ - 是否有比使用 C++ 的 FindFirstFile/FindNextFile 更快的枚举文件夹的替代方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15351288/