typedef vector pathlist; pathlist pl; void iteratorPath(string path) { _finddata_t FindData ; intptr_t hFile; pl.clear(); char FindPath[1024]; char FullName[1024]; int pathlen = (int)strlen( path.c_str() ); strncpy( FindPath, path.c_str(), pathlen ); if( FindPath[ pathlen - 1 ] != '//' ) FindPath[ pathlen++ ] = '//'; FindPath[ pathlen ] = 0; strncpy( FullName, FindPath, pathlen ); FullName[ pathlen ] = 0; strcat( FindPath, "*" ); hFile = _findfirst( FindPath, &FindData; ); do { if( FindData.name[0] != '.' ) { strcat( FullName, FindData.name ); pl.push_back(FullName); FullName[ pathlen ] = 0; } }while( _findnext( hFile, &FindData; ) == 0 ); _findclose( hFile ); } 读取: unsigned i; string pFilePath,text; FILE* pf2; for(i = 0; i < pl.size(); i++) { pFilePath = pl[i]; pf2 = fopen( pFilePath.c_str(), "rb" ); fseek( pf2, 0 ,SEEK_END ); int len = (int)ftell( pf2 ); char* buf = new char[ len + 1 ]; fseek( pf2, 0 ,SEEK_SET ); len = (int)fread( buf, 1, len, pf2 ); fclose(pf2); buf[len] = 0; text = buf; fout << pFilePath << endl; fout << text<< endl; delete []buf; }