List Files In Directory?

Started by
8 comments, last by slashandburn 21 years, 12 months ago
I have a program Im making for school, using the "Marine biology" casestudy as a guide(reference, More like i have never looked at it and made my aquarium in 3d while everyone''s elses is a 2d matrix), and i just want mine to be 200% better then all the others in my class, How can i get(retrieve) all the file names in a folder. Like pass a function a directory(apstring) and it returns a vector(apvector) containing strings(APSTRINGS) of all the files in that directory.
Advertisement
Use FindFirstFile, FindNextFile, and FindClose from Win32.

Alternatively, MSVCRT provides _findfirst, _findnext and _findclose.

Can I by any chance see what you've done to the case study files? I'm pretty amazed that someone decided to improve on AP classes. You're taking the AB test, right?

[edited by - IndirectX on April 17, 2002 12:01:54 AM]
---visit #directxdev on afternet <- not just for directx, despite the name
I mostly have rewritten the entire class structure to be easier for my extreme changes. Apvector and matrix and apstring were changed to include "windows.h" so they give errors in popups instead of couts, since im not using a console.

The Structure of it is like this(Sorta)
Notes*
The simulation class and neigbor class were combined with environment and plot. Instead of 1 fish perblock i allow for 10(Look for squares with 2 or 3 fish stacked on each other).
They can only eat, breed things in their same square.

Theyre are 3 images of what i have made so far at.

http://www.geocities.com/vbslashandburn/fish1.jpg
http://www.geocities.com/vbslashandburn/fish2.jpg
http://www.geocities.com/vbslashandburn/fish3.jpg

(Master Class) Holds all information.
(Environment Class)
Holds all fish and effects, also does all stepping. Move was removed from the fish.
Effects are like when toxic waste barrels fall down and destroy the fish. Or the cool air bubles.
(Fish Class) Holds information about fish
Food Amount
X Position
Y Position
Gender
Race (Silver or blue, etc skin)
Diet (Meat or algae)
Hungry (Am i hungry)
Pregnat(Am I)
Age (WorldTime) (How Old am I)
(Plot Class)
Number of fish im a block of land, Up to 10
(Static Object Class)
Holds information about "Reefs", "Crabs", "Starfish", "Seaweed"
X Y Z Position
(WorldTime Class)
Tells how old a object (Fish, Or world is)
Used for Night / Day Cycle
Impressive. Maybe you should post a demo or something when you''re finished.
---visit #directxdev on afternet <- not just for directx, despite the name
I might, I think it would be over 800K with all the resource files (Textures, 3D Modles)

And how are those functions used to return file names?
They stuff them into WIN32_FIND_DATA you pass to them.
---visit #directxdev on afternet <- not just for directx, despite the name
Is theyre an example i can use, im still new to the windows things.
Untested:

  WIN32_FIND_DATA wfd;HANDLE hFind = FindFirstFile("*.dat", &wfd);if (hFind){	do {		apstring filename = wfd.cFileName;	// convert to apstring if you want, or use cFileName directly							// you can also use other members of wfd, like file size	} while (FindNextFile(hFind, &wfd));	FindClose(hFind);}  
---visit #directxdev on afternet <- not just for directx, despite the name
Thanks, now i can make a neat user interface to select the environment to load.
As a side note: since you''re redoing most of the AP stuff anyway, why not use STL? It seems much more efficient and certainly has more functionality.
---visit #directxdev on afternet <- not just for directx, despite the name

This topic is closed to new replies.

Advertisement