Hello,
i have a problem. I would like to print out everything that is on a hard drive. Like c: or d: etc...
For now i came up with this:
Code:
#include <stdarg.h>
#include <stdio.h>
#include <windows.h>
#include <string.h>
void IzpisiDir(char Pot[])
{
WIN32_FIND_DATA podatki;
HANDLE rocka;
char tmpPot[MAX_PATH];
char tmp[MAX_PATH];
char zvezda[]="*.*";
strcpy(tmpPot, Pot);
strcat(tmpPot, zvezda);
rocka = FindFirstFile(tmpPot,&podatki);
if(rocka==INVALID_HANDLE_VALUE)
return;
do
{
if(podatki.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
printf("%s", podatki.cFileName);
//if((0 != strcmp(podatki.cFileName,".")) && (0 != strcmp(podatki.cFileName,"..")));
strcpy(tmpPot, Pot);
strcat(tmpPot, podatki.cFileName);
strcat(tmpPot,"\\");
strcat(tmpPot, zvezda);
}
else
printf(" %s\n",podatki.cFileName);
}
while(FindNextFile(rocka,&podatki));
FindClose(rocka);
}
int main()
{
IzpisiDir("C:\\");
}
I just don't know how to print out a folder go into that folder print out everything that is in there and then go back out of the folder and move on to the next one like:
temp (directory)
test.ini
test01.ini
cboard(directory)
cboard.doc
cboard.pdf
... and so on
I just print out some of the folders and files.
Can somebody give me some pointer please. I've been doing this for 4 days now and i don't have any idea or energy to go on.
Thank you in advance.