遍历文件夹(仅限当前目录而不深入)下的文件#include <io.h>#include <fstream>#include <string>void getJustCurrentDir( string path, vector<string>& files, const char* typeName = NULL) { //文件句柄 long hFile = 0; //文件信息 struct _finddata_t fileinfo; string p; string type;string type_head;if (path[path.length()-1] != '\\')type_head = string("\\");if (typeName != NULL){type = type_head + string(typeName);}else{type = type_head + string("*");}if((hFile = _findfirst(p.assign(path).append(type).c_str(), &fileinfo)) != -1) {do{if((fileinfo.attrib & _A_SUBDIR)){;}else{files.push_back(fileinfo.name);//files.push_back(p.assign(path).append("\\").append(fileinfo.name) );}}while(_findnext(hFile, &fileinfo) == 0);_findclose(hFile); } }
,生命不在长而在于好,只要每一次尽力的演示,都值得鼓励与喝采。