2009-11-12 132 views

回答

2

Boost有一個偉大的平臺無關filesystem library。它將使用MFC。

下面是一個例子,從their reference

#include <iostream> 
#include <filesystem> 

using std::tr2::sys; 
using std::cout; 

int main(int argc, char* argv[]) 
{ 
    std::string p(argc <= 1 ? "." : argv[1]); 

    if (is_directory(p)) 
    { 
    for (directory_iterator itr(p); itr!=directory_iterator(); ++itr) 
    { 
     cout << itr->path().filename() << ' '; // display filename only 
     if (is_regular_file(itr->status())) cout << " [" << file_size(itr->path()) << ']'; 
     cout << '\n'; 
    } 
    } 
    else cout << (exists(p) ? "Found: " : "Not found: ") << p << '\n'; 

    return 0; 
} 
0

還有CListBox::Dir。如果你想用文件名填寫一個列表框,這非常方便。

相關問題