简体   繁体   English

是否返回FindFirstFile / FindNextFile API对缓存结果?

[英]Does FindFirstFile/FindNextFile API pair cache results returned?

I'm not sure if this was asked already, I can't seem to find it. 我不确定是否已被问到,我似乎找不到。

When I'm doing a folder contents enumeration, you know the usual: 当我进行文件夹内容枚举时,您会知道通常的情况:

FindFirstFile();
do
{
}while(FindNextFile());

What happens if while I'm still in my do/while loop the contents of the folder change? 如果我仍在do/while循环时文件夹的内容发生更改,会发生什么情况? Say, a new file or a folder is added, altered or removed. 假设添加,更改或删除了新文件或文件夹。 Is that reflected in the results returned by FindNextFile ? 这是否反映在FindNextFile返回的结果中?

A quick test case shows that FindFirstFile does not cache the results on a local filesystem running on Windows 7. But as soon as FindNext is called, the results are cached (not fully, only a little bit). 一个快速的测试案例表明,FindFirstFile不会将结果缓存在运行Windows 7的本地文件系统上。但是,一旦调用FindNext,结果就被缓存了(不完全,只有一点点)。 But since this is not documented in the Windows SDK, it must be seen as an implementation detail, which could change at any time. 但是,由于Windows SDK中未记录此内容,因此必须将其视为实现细节,并且可以随时更改。 So write your code in a way that it does not depend on this behavior. 因此,以不依赖此行为的方式编写代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 FindFirstFile,FindNextFile API是否不可靠? - Are FindFirstFile, FindNextFile APIs unreliable? FindFirstFile和FindNextFile问题 - FindFirstFile and FindNextFile question 在DLL中包装FindFirstFile / FindNextFile / FindClose - Wrapping FindFirstFile/FindNextFile/FindClose in a DLL 使用 findfirstfile 和 findnextfile 在子目录中搜索 - use findfirstfile and findnextfile to search in subdirectories 为什么FindFirstFile / FindNextFile有时会在网络文件夹中看到一个文件,但CopyFile却没有? - Why do FindFirstFile / FindNextFile sometimes see a file on a network folder, but CopyFile does not? Windows FindFirstFile / FindNextFile API是否有不搜索短文件名的替代方法? - Is there an alternative to the Windows FindFirstFile/FindNextFile API that doesn't search short file names? FindFirstFile / FindNextFile不返回文件夹中的所有文件 - FindFirstFile/FindNextFile not returning all files in folder 使用FindFirstFile和FindNextFile递归查找具有特定扩展名的文件 - Recursively find files with a certain extension using FindFirstFile and FindNextFile 使用C ++比使用FindFirstFile / FindNextFile枚举文件夹有更快的替代方法吗? - Is there a faster alternative to enumerating folders than FindFirstFile/FindNextFile with C++? 使用FindFirstFile和FindNextFile C ++进行递归硬盘搜索 - Recursive hard disk search with FindFirstFile & FindNextFile C++
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM