Hi guys...
The following code works fine and ouputs a list of all the files within the c drive when i enter the directory myself i.e
Code:
void OpenDirectory(string File)
{
WIN32_FIND_DATA w32;
ZeroMemory( &w32, sizeof(w32) );
HANDLE h = FindFirstFile( "C:\\*.*", &w32 ); // Works with this
string hold;
hold = w32.cFileName;
CheckFile(hold);
while ( FindNextFile( h, &w32 ))
{
hold = w32.cFileName;
cout << hold << endl;
}
}
However if i pass the drive in a string and then place that string into a char array, the program compiles but outputs nothing.
Code:
int main()
{
OpenDirectory("C:\\*.*");
return 0;
}
void OpenDirectory(string File)
{
int length = File.size();
char newFile[length];
int i;
for (i = 0; i < length; i++)
{
newFile[i] = File.at(i);
}
WIN32_FIND_DATA w32;
ZeroMemory( &w32, sizeof(w32) );
HANDLE h = FindFirstFile( newFile, &w32 ); // Doesn't work
string hold;
hold = w32.cFileName;
CheckFile(hold);
while ( FindNextFile( h, &w32 ))
{
hold = w32.cFileName;
cout << hold << endl;
}
}
I've tried everything i could think of but i can't get it to output anything. If i try using the string without placing it into a char array the program doesn't even compile, anyone got any ideas
Cheers Mike...