Jump to content
  • Advertisement

Archived

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

ATronic

File loading

This topic is 6073 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

Hey all, I was wondering how to get all of the files existing in a directory. Up until now whenever I added a data file to my game projects I have put it's name in an index file. But is there some way to find out what files exist in a given directory? So, for example, if I put a plugin there my game or app would find it? Any help is greatly appreciated. Alex Broadwin A-Tronic Software & Design ----- "if you fail in life, you were destined to fail. If you suceed in life, call me." "The answer is out there." "Please help, I'm using Windows!" Edited by - ATronic on February 1, 2002 10:14:06 AM

Share this post


Link to post
Share on other sites
Advertisement
check findfirstfile and findnextfile in msdn (in case you don''t have it go to msdn.microsoft.com and use search (left part of www page) , it''s pretty simple to use

With best regards,
Mirek Czerwiñski
http://kris.top.pl/~kherin/

Share this post


Link to post
Share on other sites
Thanks a ton. That should make things a lot better.

Alex Broadwin
A-Tronic Software & Design
-----
"if you fail in life, you were destined to fail. If you suceed in life, call me."
"The answer is out there."
"Please help, I''m using Windows!"

Share this post


Link to post
Share on other sites
Checked it out, not what I need. That searches _by filename_. I need a way to get files in a directory, when I don''t know how many are there, or what they are called. Anyone?

Alex Broadwin
A-Tronic Software & Design
-----
"if you fail in life, you were destined to fail. If you suceed in life, call me."
"The answer is out there."
"Please help, I''m using Windows!"

Share this post


Link to post
Share on other sites
FindFirstFile can take a mask as it's input. So passing X:\DirectoryName\*.* should allow you to work through all files in the dir.

  
WIN32_FIND_DATA fileData;
HANDLE fileHandle;

fileHandle = FindFirstFile("C:\\WINNT\\*.*", &fileData);
if (fileHandle != INVALID_HANDLE_VALUE)
{
cout << fileData.cFileName << "\n";
while (FindNextFile(fileHandle, &fileData))
{
cout << fileData.cFileName << "\n";
}
}


Edited by - MonkeyChuff on February 1, 2002 10:48:41 AM

Share this post


Link to post
Share on other sites
yup, MonkeyChuff is right, this way you can search only for specific file types like *.tga etc.
You didn''t read msdn decription propertly, did you?


With best regards,
Mirek Czerwiñski
http://kris.top.pl/~kherin/

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!