在C ++中,什么是在Windows上列出目录的所有文件的最佳方法?

在Linux上或使用gcc(例如MingW)的Windows上,可以通过dirent.h轻松实现,但是当dirent.h不可用(例如Visual Studio)时,在Windows上执行此操作的最佳方法是什么?

我应该强迫人们在他们的Visual Studio中添加dirent.h的免费实现吗?还是应该编写替代代码来读取文件?如果是这样,最好的代码是什么?

谢谢。

有帮助吗?

解决方案

类似于 Boost文件系统的东西在所有这些情况下。

其他提示

dirent.h is a POSIX header. On Windows you use the Find*File*() functions in the Win32 API.

To add to the answer above, Windows API is accessed via the windows.h header file included.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top