Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Fuzz

reading directory file information

This topic is 6912 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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++??

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!