So, here is my problem:
I want to list all files of my main drive for example "C:\"
This could be realized with the FindFirstFile() and FindNextFile()
functions from the WinApi but also need a recursive function calling.
How to realize ?
Code:
scroll down !
-------------------------------------------------------------------------------
Also hier mein Problem:
Ich möchte alle Dateien von meiner Hauptfetplatte z.B "C:\"
auflisten. Dies kann mit den FindFirstFile() and FindNextFile() Funktionen
aus der WinApi realisiert werden benötigt aber die Verwendung rekursiver
Funktionsaufrufe.
Wie realisisere ich dass ?
Hier ist mein Code:

Code:

//Only a example so please don't blame me for syntax errors

#include <acknex.h>
#include <windows.h>
#include <stdio.h>

/*here I defined the WIN32_FIND_DATA and FILETIME structs furthermore the
TCHAR definitions*/

char main_str[10000]; //enough space ?

int list_files(char *dir) //for recursion
{
HANDLE main_handle;
WIN32_FIND_DATA main_data;
char path_str[500];

main_handle = FindFirstFile(dir,&main_data);

while(FindNextFile(main_handle,&main_data))
{
switch(main_data.dwFileAttributes)
{
case FILE_ATTRIBUTE_DIRECTORY:
sprintf(main_str,"[dir]");
sprintf(main_str,main_data.cFileName);
sprintf(main_str,"\n");
GetFullPathName(main_data.cFileName,path_str,4096,NULL);
list_files(path_str);
break;
default:
sprintf(main_str,"[file]");
sprintf(main_str,main_data.cFileName);
sprintf(main_str,"\n");
/*All other switches like FILE_ATTRIBUTE_ARCHIVE,etc.*/
}
}

int main()
{
wait(1);
list_files("C:\\*");
}



So far
But at the end the string only contains the files of the
folder given at the first function call ("C:\\*") and the
names of all subdirectories but not their files, so please help me.
-------------------------------------------------------------------------------
So weit
Aber der String enthält am Ende nur die Dateien des Verzeichnisses, dass beim
ersten Funktionsaufruf angegeben wurde ("C:\\*") und die Namen der Unter
verzeichnisse aber nicht deren Dateien.