I have situation where i have to take all the files from the directory and to display name of each individual files and their size. I tried with the following way. Is this the right approach. thank you!!!
#include <boost/filesystem.hpp>
#include <boost/range/iterator_range.hpp>
#include <ftream>
#include <iostream>
using namespace std;
int main () {
std::string SourceFolder="C:\\testFolder\\";
path mDirectory(SourceFolder);
boost::system::error_code ec;
std::ifstream InputStream;
std::cout<<"Directory includes the following files"
if(is_directory(mDirectory)){
for(auto testFile=mDirectory.begin();testFile!=mDirectory.end();testFile++){
std::cout<< testFile->string()<<std::endline;
std::cout<<"size in [MB] = "<< file_size(*testFile,ec)<<std::endline;
}
return 0;
}
Aucun commentaire:
Enregistrer un commentaire