二.

void readImgNamefromFile(char* fileName, vector<string>& imgNames)
{
// vector清零,参数设置 imgNames.clear(); WIN32_FIND_DATA file; int i = 0; char tempFilePath[MAX_PATH + 1]; char tempFileName[50]; // 转换输入文件名 sprintf(tempFilePath, "%s/*", fileName);

 // 多字节转换
 WCHAR wstr[MAX_PATH] = {0};
 MultiByteToWideChar(CP_ACP, 0, tempFilePath, -1, wstr, sizeof(wstr)); // 查找待操作文件的相关属性,读取到WIN32_FIND_DATA HANDLE handle = FindFirstFile(wstr, &file); if(handle != INVALID_HANDLE_VALUE) { FindNextFile(handle, &file);
   FindNextFile(handle, &file); // 循环遍历得到文件夹的所有文件名 do { sprintf(tempFileName, "%s", fileName); imgNames.push_back(WChar2Ansi(file.cFileName)); imgNames[i].insert(0, tempFileName); i++; } while(FindNextFile(handle, &file)); } FindClose(handle); }

 

相关文章:

  • 2022-02-21
  • 2022-12-23
  • 2021-10-03
  • 2021-09-06
  • 2021-12-01
猜你喜欢
  • 2021-08-16
  • 2022-12-23
  • 2022-02-07
  • 2021-09-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案