Jump to content
  • Advertisement


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


Win32 File Searching in A Specific Directory

This topic is 5557 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 Im having probs with searching a certain directory for files using FindFirstFile and FindNextFile. Platform SDK says: hSearch = FindFirstFile("*.txt", &FileData); ^ That would search for all .txt files,if I understand correctly. But what if I wanted to search a specific directory? Ive made a select directory dialog that will get the dir name to be searched but I dont know if its format is correct. The dirname gets stored in a TCHAR array like so called "szFolder[MAX_PATH] and it holds "C:\AFolder" which the select directory puts in, which is correct but if I use that in FindFirstFile it will only give me the info about the directory and not the files in it. If the above format is correct how would I change the string to hold the current directory plus "\*.*" next to it. i.e "C:\AFolder\*.*" Basically I just want to search a specific directory for all files. Please Help Thanks :D

Share this post

Link to post
Share on other sites
strcat(szFolder, "\\*.*")

Then if you FindFirstFile with szFolder it will look for all the files in whatever folder was in szFolder.

Share this post

Link to post
Share on other sites
Hey darkchrono4

Ok ive done what uve said buts its still giving me wrong info about the files.

After i inserted the line you told me to it reports it as:


which is what I want,but it still doesnt work,im trying to get it to put all the filenames in a .txt file. But all I get is sum gobbledy gook in the file (info on directory itself?).

However if I enter the path manually like so:


It works perfectly. I dont know what I should do to enter the second ''\'' after "C:\". And also no idea why even tho I added the above function into my code the second pair of backslashes arnt double like "\\" but instead theyre ''\''.

Any suggestions?

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.

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!