c++11 - how to get file names vs directory names in c++ (using boost filesystem library) -
when use boost::filesystem
list of file names in directory, receive file names directory names:
#include <string> #include <iostream> #include <boost/filesystem.hpp> using namespace std; using namespace boost::filesystem; int main() { path p("d:/anyfolder"); (auto = directory_iterator(p); != directory_iterator(); i++) { cout << i->path().filename().string() << endl; } }
output like:
file1.txt file2.dat folder1 //which folder
is there quick way distinguish between files , folders? os windows 8.1, if matters.
boost::filesystem::is_directory(i->path());
Comments
Post a Comment