1. 方法1
# include <io.h>
bool LoadAllImageDirs(string dir_root,vector<string>& filenames)
{
DIR *pDir;
struct dirent* ptr;
if(!(pDir = opendir(dir_root.c_str()))){
return false;
}
while((ptr = readdir(pDir))!=0) {
if (strcmp(ptr->d_name, ".") != 0 && strcmp(ptr->d_name, "..") != 0){
filenames.push_back(dir_root + "/" + ptr->d_name);
}
}
closedir(pDir);
return true;
}
2. 其他
参考另一篇博文解决办法:_findnext()报错