Forum > Beginners

Recursive search for a specific file

(1/5) > >>

JLWest:
I would like to search a sub directory and all sub directories within for a  file 'MyFile.txt'.  and return the path and file name. There would be more than one occurrence of 'MyFile.txt'.

Is there a control or something besides FillAllFiles or do I have to write this from scratch?

lucamar:
This recent topic may be helpful for you: File path from search results.

Don't discard it because the title: as always, we divaged widely :)

jamie:
by the time you get done,  you would end up with the same "FindAllFiles"

is there a reason you want to do this manually in your code?

JLWest:
No no reason.
Just hoping someone has done this before or there was a control that would do a recursive search and reture a list of the file.

lucamar:

--- Quote from: JLWest on March 09, 2019, 10:21:24 pm ---No no reason.
Just hoping someone has done this before or there was a control that would do a recursive search and reture a list of the file.

--- End quote ---

The closest control is the TFileListBox and it's not very close to what you want. In the thread I linked to you'll find my example of how something like this could be done. It uses FindAllFiles() because it's very convenient for quick examples but you'll have more control using a TFileSearcher or TListFileSearcher class.

It's DIY country, but you can subclass a TListBox to build something like the TFileListBox but using any of the above function/classes to show more than just the current directory. It shouldn't be unreasonably difficult ;)

Navigation

[0] Message Index

[#] Next page

Go to full version