使用了C++17很好用的filesystem, 再也不用boost的文件系统了,上代码,实现了读取某个文件夹下面文件和子文件夹及其所有文件!
#include <fstream>
#include <iostream>
#include <string>#include <sstream>
#include <vector>
#include <io.h>
#include <experimental\filesystem>
using namespace std;
namespace fs = std::experimental::filesystem;
void getAllFiles(fs::path strPath, vector<fs::path>& files)
{
for (auto& fe : fs::directory_iterator(strPath))
{
auto fp = fe.path();
auto fFiename = fp.filename();