fork download
  1. if(this->folderBrowserDialog1->ShowDialog()==System::Windows::Forms::DialogResult::OK)
  2. {
  3. WIN32_FIND_DATA FindFileData;
  4. HANDLE hFind;
  5.  
  6. char* temp="\\*.png";
  7. char* szPath=(char*)(void*)Marshal::StringToHGlobalAnsi(folderBrowserDialog1->SelectedPath);
  8. strcat(szPath,temp);
  9. cout << szPath << endl;
  10. hFind=FindFirstFile(szPath,&FindFileData);
  11.  
  12. if(hFind!=INVALID_HANDLE_VALUE){
  13. cout << FindFileData.cFileName << endl;//第一個檔名
  14.  
  15. // >>>>>
  16. char *f = (char *)malloc(strlen(FindFileData.cFileName) + 1);
  17. strcmp(f, FindFileData.cFileName);
  18. fileNames.push_back(f);
  19. // fileNames.push_back(FindFileData.cFileName);
  20. // <<<<<
  21.  
  22. while(FindNextFile(hFind,&FindFileData)){
  23. cout << FindFileData.cFileName << endl;//接下來的檔名
  24. fileNames.push_back(FindFileData.cFileName);
  25. }
  26. for(vector<char*>::iterator it = fileNames.begin();it != fileNames.end();it++)
  27. cout << *it <<endl;
  28. }
  29. else
  30. printf("查無檔名\n");
  31. FindClose(hFind);
  32. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty