Here is the program:
#include <stdio.h>
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
const char c[] = "C:\Users\*.*";
hFind = FindFirstFile(c, &FindFileData);
if (hFind == INVALID_HANDLE_VALUE)
{
printf("FindFirstFile failed (%d)n", GetLastError());
return 1;
}
else
{
cout << "The first file found is " << FindFileData.cFileName << endl;
}
for (int i = 0; i < 12; i++)
{
if (!FindNextFile(hFind, &FindFileData))
{
printf("FindNextFile failed (%d)n", GetLastError());
}
else
{
cout << "The next file found is " << FindFileData.cFileName << endl;
}
}
FindClose(hFind);
return 0;
}
Prints this:
No matter what directory I goto, it always prints the first two lines with file . and .. ? why is that?
Aucun commentaire:
Enregistrer un commentaire