noob
noob

Reputation: 133

how to search for a file in all drives

hey how can i search for a file in HDD ,

example i wanna search for a file settings.ini in my computer .

Upvotes: 1

Views: 1504

Answers (2)

otherchirps
otherchirps

Reputation: 1846

Just adding to the FindFirst/FindNext advice:

Take care with the "." and ".." directory names that come back. Otherwise, you may never run out of items to walk.

Also keep watch for anything coming back, in the WIN32_FIND_DATA result, with the FILE_ATTRIBUTE_REPARSE_POINT flag set. That'll probably be a symlink, and where it goes might also give you an infinite walk. An example can be seen over at the Old New Thing.

Upvotes: 0

gabr
gabr

Reputation: 26830

First you have to get a list of valid drives. This was discussed previously on the StackOverflow.

The you have to call FindFirst/FindNext/FindClose on the root folder of each drive. Get a list of files and directories. Check the list of files. Repeat this for each directory. Until you run out of directories. Search for "[delphi] findfirst" on StackOverflow to find more information.

Upvotes: 4

Related Questions