简体   繁体   English

c++,列出 Windows 上的所有文件,dirent.h

[英]c++, List all files, dirent.h on Windows

in C++, what would be the best way to list all files of a directory on Windows?在 C++ 中,列出 Windows 上目录的所有文件的最佳方法是什么?

On Linux or on Windows using gcc (eg MingW) this is easy possible with dirent.h, but what's the best way to do it on Windows when dirent.h is not available (eg Visual Studio)? On Linux or on Windows using gcc (eg MingW) this is easy possible with dirent.h, but what's the best way to do it on Windows when dirent.h is not available (eg Visual Studio)?

Should I force people do add a freely available implementation of dirent.h to their Visual Studio?我是否应该强迫人们在他们的 Visual Studio 中添加一个免费提供的 dirent.h 实现? Or should I write an alternative code for reading the files?或者我应该写一个替代代码来读取文件? If this, what would be the best code to do so?如果是这样,最好的代码是什么?

Thanks.谢谢。

dirent.h is a POSIX header. dirent.h是一个 POSIX header。 On Windows you use the Find*File*() functions in the Win32 API.在 Windows 上,您使用 Win32 API 中的Find*File*()函数。

Something like Boost Filesystem would work across all of those situations.Boost Filesystem这样的东西可以在所有这些情况下工作。

To add to the answer above, Windows API is accessed via the windows.h header file included.要添加到上面的答案,Windows API 通过包含的 windows.h Z099FB995346F31C749F6E0DBD 文件访问。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM