Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Loading All of the files in a directory

Author
Message
Ninjateck
16
Years of Service
User Offline
Joined: 27th Feb 2008
Location:
Posted: 25th Apr 2010 20:56
Im trying to figure out how to display all of the files in a directory and save the list to a txt file
i think this could be done with dbFindNext and a loop but a cant figure out how to tell when ive reached the last file and i cant figure out how to code the loop properly.

so far ive got


but that would take forever to code and i want the code to work with any size directory
Bran flakes91093
16
Years of Service
User Offline
Joined: 13th Sep 2008
Location: Crazy Land
Posted: 25th Apr 2010 23:02 Edited at: 27th Apr 2010 21:46


Dirty, but it gets the job done.

"A computer once beat me at chess, but it was no match for me at kick boxing."
Emo Philips
haliop
User Banned
Posted: 27th Apr 2010 01:39
yeah thats actually very simple.
i thank you for that.
Ninjateck
16
Years of Service
User Offline
Joined: 27th Feb 2008
Location:
Posted: 27th Apr 2010 18:07 Edited at: 27th Apr 2010 19:25
Ok, thanks but i have some questions, will this load subdirectories ?
and does it belong in the main loop ? how should i set it up in my program ?

basicly, does your code create two strings, one the previous dbGetFileName() and one the current ? and stops when the two are equal two each other ? if so, where should i place my write to file code ?

EDIT: i tried reproducing your code with different var names and im having problems

pstring is never equal to lstring
the result is a 10mb txt file with the last result repeated hundreds of times
Bran flakes91093
16
Years of Service
User Offline
Joined: 13th Sep 2008
Location: Crazy Land
Posted: 27th Apr 2010 21:46
The two variables are pointers, which point to an address in memory, and are not actual strings. Read up on character sequences and pointers here.
Use strcmp.

The only way that I could tell if dbFindNext had found the last file was to store the last file name. When it is on the last file and you call dbFindNext, it stays on the same file, and there cannot be two files with the exact same name (and extension) in one directory.

It only loads the current directory, and not subfolders.

"A computer once beat me at chess, but it was no match for me at kick boxing."
Emo Philips

Login to post a reply

Server time is: 2024-11-20 01:20:10
Your offset time is: 2024-11-20 01:20:10