// 读取文件夹中所有的文件
int getFilesName(std::string path, std::vector<std::string>& files) {
intptr_t hFile = 0;
struct _finddata_t fileinfo;
std::string p;
if ((hFile = _findfirst(p.assign(path).append("\\*").c_str(), &fileinfo)) != -1) {
do {
if ((fileinfo.attrib & _A_SUBDIR)) {
if (strcmp(fileinfo.name, ".") != 0 && strcmp(fileinfo.name, "..") != 0)
getFilesName(p.assign(path).append("\\").append(fileinfo.name), files);
}
else {
files.push_back(p.assign(path).append("\\").append(fileinfo.name));
}
} while (_findnext(hFile, &fileinfo) == 0);
_findclose(hFile);
}
return 0;
}
30.C++读取文件夹中所有文件
最新推荐文章于 2024-07-23 10:37:38 发布