Boost Filesystem
my directory structure is "C:\test\two\data\1111"
how do i modify the code below so that i will only get
"C:\test\two"
instead of
"C:\test\two"
"C:\test\two\data\"
"C:\test\two\data\1111"
1 2 3 4 5 6 7
|
#include "boost/filesystem.hpp"
#include <iostream>
for ( boost::filesystem::recursive_directory_iterator end, dir("C:\\test");
dir != end; ++dir ) {
cout << *dir << std::endl;
}
|
thanks
Don't use a recursive iterator.
do you know how do to search for all folders in a directory.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
#include "boost/filesystem.hpp"
#include <iostream>
#include <string>
int main()
{
namespace fs = boost::filesystem ;
const std::string testPath = "C:/test" ;
for ( fs::directory_iterator dir(testPath), end; dir != end ; ++dir )
if ( fs::is_directory(*dir) )
std::cout << *dir << '\n';
}
|
http://www.boost.org/doc/libs/1_54_0/libs/filesystem/doc/tutorial.html
Last edited on
Thanks a lot.
Topic archived. No new replies allowed.