簡體   English   中英

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

[英]c++, List all files, dirent.h 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)?

我是否應該強迫人們在他們的 Visual Studio 中添加一個免費提供的 dirent.h 實現? 或者我應該寫一個替代代碼來讀取文件? 如果是這樣,最好的代碼是什么?

謝謝。

dirent.h是一個 POSIX header。 在 Windows 上,您使用 Win32 API 中的Find*File*()函數。

Boost Filesystem這樣的東西可以在所有這些情況下工作。

要添加到上面的答案,Windows API 通過包含的 windows.h Z099FB995346F31C749F6E0DBD 文件訪問。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM