使用 C 和 Windows 列出目录内容
我希望在 Windows 上使用 C 列出目录的内容并将其存储在结构中。
我不一定要找人写出我正在寻找的代码,而是在我应该查看哪个库时为我指明正确的方向。
我已经在谷歌上搜索了几个小时,我找到的只是 C#、C++ 解决方案,因此任何帮助将不胜感激。
I'm looking to list and store the contents of a directory in a struct using C on Windows.
I'm not necessarily looking for anyone to write out the code I'm looking for, rather point me in the right direction when it comes to which library I should be looking at.
I've been Googling for a few hours now and all I'm finding is C#, C++ solutions so any help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
就像其他人所说的那样(使用 FindFirstFile、FindNextFile 和 FindClose)...但是使用递归!
现在它的 UNICODE 对应项:
Just like everyone else said (with FindFirstFile, FindNextFile and FindClose)... but with recursion!
And now its UNICODE counterpart:
可能您正在寻找以下函数: FindFirstFile 、FindNextFile 和 查找关闭。
Probably You are looking for these functions: FindFirstFile, FindNextFile, and FindClose.
要列出文件内容,您可以使用以下 API 搜索目录: FindFirstFileEx、FindNextFile和查找关闭。您需要
#include
,这将使您能够访问Windows API。它们是 C 函数,因此与 C++ 兼容。如果您想要“专门针对 C++”,请尝试使用 MFC 搜索列表目录。To list file contents you can search a directory with these APIs: FindFirstFileEx, FindNextFile and FindClose. You'll need to
#include <windows.h>
, that'll get you access to the Windows API. They're C functions and so compatible with C++. If you want "specifically C++", try searching for listing directories using MFC.