_findnext,_finddata_t在64位系统操作失败

原程序:

void GetFiles(std::string path, std::vector<std::string>& files) {
  // 文件句柄
  long hFile = 0;
  // 文件信息
  struct _finddata_t fileinfo;
  std::string p;
  if ((hFile = _findfirst(p.assign(path).append("\\*").c_str(), &fileinfo)) != -1) {
    do {
	 
		std::cout << "the path is " << path << std::endl;
	  if((fileinfo.attrib &  _A_SUBDIR)) {
		if (strcmp(fileinfo.name, ".") != 0 && strcmp(fileinfo.name, "..") != 0)
		  GetFiles(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);
  }
}

 这里的long hFile不对,需要写成intptr_t hFile

虽然是小bug,写出来,让别人很快搜索到,方便你我!

posted on 2016-01-27 23:00  KillU  阅读(649)  评论(2)    收藏  举报

导航