Archived

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

Shock

Win32 File Searching in A Specific Directory

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
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:

"C:\AFolder\*.*"

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:

"C:\\AFolder\\*.*"

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