🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

reading directory file information

Started by
1 comment, last by Fuzz 24 years, 1 month ago
how do you see what files are in a directory? I want my program to see what files are in a directory and automatically add them into its data structures, but I dont know how to view a directory''s filenames. Any ideas how to do it in C/C++??
Advertisement
Well if you wanted to do it in Windows this is how I would do it:

If you have the Win32 SDK help installed or on CD read up on these functions, they''re pretty straightforward and work fairly well.

use:
FindFirstFile() and FindNextFile()
you have to set parameters for the functions basically limiting what type of files you want to look for. ie: if you wanted only to search files of 3ds max you could set it to look for *.3ds.. and so on.

You have to continuously loop FindNextFile() until it returns that no more files are found.

If you don''t have the SDK help installed reply again on this message board and I can paste some raw code to explain in more detail on how to do it.

Hope this leads you in the direction you were expecting.

This Space Left Blank
Thanks for your help.. I tried those functions, but for some reason I get linking errors when I use then (no errors or warnings tho). I think I might just issue a system command.. like "dir > temp" and read in the information in temp. I just did some more digging today, and found another findfirst and findnext. They work the same way as you mentioned, but arent part of the WIN32 SDK. I''ll see if they work without linking errors. (BTW the linking errors were saying something like the delete and new functions were already defined, and my code was fine before I added the findFirstFile function)

Thanks again

This topic is closed to new replies.

Advertisement