windows下遍历文件夹

综述

windows下遍历文件夹

代码

#include 
#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;
vector  list_all_files(string folder)
{
	vector names;
	string search_path = folder + "/*.*";
	WIN32_FIND_DATA fd;
	HANDLE hFind = ::FindFirstFile(search_path.c_str(), &fd);
	if (hFind != INVALID_HANDLE_VALUE) {
		do {
			if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
				names.push_back(folder+"//"+fd.cFileName);
			}
		} while (::FindNextFile(hFind, &fd));
		::FindClose(hFind);
	}
	return names;
}


你可能感兴趣的:(VS,windows)