Γεια σας! Προσπαθω να γραψω κωδικα ωστε να κανω αναζητηση αρχειων σε καποιο φακελο στο δισκο οπως επισης και στους υποφακελους κτλ. Εχω τον παρακατω κωδικα:
#define _WIN32_WINNT 0x0501
#include <Windows.h>
#include <iostream>
#include <string>
using namespace std;
int SearchDir( string directory );
int main(int argc, TCHAR *argv[])
{
SearchDir( "E:" );
}
int SearchDir( string directory )
{
//int x = 0;
WIN32_FIND_DATA FindData;
HANDLE hFind = INVALID_HANDLE_VALUE;
string scan = directory + "//*";;
hFind = FindFirstFile( scan.c_str(), &FindData );
if ( hFind == INVALID_HANDLE_VALUE )
{
return 1;
}
if ( FindData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY )
{
string dirscan;
dirscan = directory + "//" + FindData.cFileName;
SearchDir( dirscan );
}
else
{
cout << FindData.cFileName << endl;
}
//cout << FindData.cFileName << endl;
//x++;
while ( FindNextFile( hFind, &FindData ) != 0 )
{
if ( FindData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY )
{
string dirscan;
dirscan = directory + "//" + FindData.cFileName;
SearchDir( dirscan );
}
else
{
cout << FindData.cFileName << endl;
}
//cout << FindData.cFileName << endl;
//x++;
}
FindClose( hFind );
cout << "========Finished========" << endl;
//cout << x << endl;
system ( "pause" );
return 0;
}
Εαν βγαλω τον κωδικα που τσεκαρει για φακελους ολα λειτουργουν κανονικα. Οταν μπαινει στον παιχνιδι και ο κωδικας αυτος ομως τοτε βγαζει οτι θελει και οπως θελει. Επειδη δεν μπορω να εξηγησω ετσι και μια εικονα = χιλιες λεξεις δοκιμασε να τρεξετε τον κωδικα και θα δειτε τι ακριβως εννοω.
Burning The Fire........