salve a tutti, vorrei avere un codice che mi legga tutte le cartelle,i file e le sottocartelle presenti nell'unità C.
So che vanno usate le API FindFirst e FindNext, ed ho arrangiato un codice per leggere tutti i file e le sottocartelle presenti in "C:\" solo che non riesco ad entrare nelle rispettive sottocartelle e leggere i file.
Ho cercato per il web, ma non riesco proprio a capire come fare. Msdn l'ho riletto un migliaio di volte.Suggerimenti?
Ecco il codice:
codice:
#include <windows.h>
#include <iostream>
int main()
{
using namespace std;
HANDLE hFind;
WIN32_FIND_DATA FindData;
// Find the first file
hFind = FindFirstFile("C:\\*.*", &FindData);
/*file process*/
cout << FindData.cFileName << endl;
// Look for more
while (FindNextFile(hFind, &FindData))
{
/*file process*/
cout << FindData.cFileName << endl;
}
// Close the file handle
FindClose(hFind);
system("pause");
return 0;
}