转载:https://www.csdn.net/gather_23/NtDaIg1sMDYtYmxvZwO0O0OO0O0O.html
Windows平台代码如下:
1 #include <windows.h> 2 3 //string to char* 4 /* 5 string path; 6 const char* tempPath = path.c_str(); 7 */ 8 9 WIN32_FIND_DATAA FindFileData; 10 FindFirstFileA("c:\1.txt",&FindFileData); 11 //FindFirstFileA(tempPath,&FindFileData); 12 if(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) 13 { 14 //Folder 15 } 16 else 17 { 18 //File 19 }