Ok I did a try now, but somehow it does not work correctly-- it allways goes to the else clause, and there it allways just couts a dot(.), not any files, for example when I input "C:\\WINDOWS\\*".
Can anyone please correct me?
Code:
// Finding first file in a folder test
#include <iostream>
#include <windows.h>
using std::cout;
using std::cin;
using std::endl;
int main() {
char folder[100];
cout << "Enter folder: ";
cin >> folder;
cout << "Checking " << folder << endl;
WIN32_FIND_DATA found;
HANDLE hFind;
hFind = FindFirstFile(folder, &found);
if (found.cFileName == NULL) { // its probably this line, but...... Why?
cout << "Folder does not exist or folder is empty." << endl;
}
else {
cout << found.cFileName << " is the first file in " << folder << endl;
}
system("pause");
return 0;
}