Searching for string occurrence within files

Community Forums/General Help/Searching for string occurrence within files

Matty(Posted 2009) [#1]
Good Morning,
I've written a program in blitzplus, (although blitz3d could have been used as well), which searches for a user supplied string in either any file or files with a specific extension throughout folders on a users hard drive.

I'm wondering if there is a faster way than the method we use which is:

read through a directory, entering sub directories if there are any (and the user wants to search sub folders) and opening each file in turn (according to filter of either "all" or "with extension xyz") and then reading in each line of the file until a match is found using the Instr() command, then exiting that file and proceeding onto the next.

It seems quite slow. Is there a better way -> and what is it?


JKP(Posted 2009) [#2]
Well, I think it's possible to access the Windows Search index via an API which is potentially a lot faster. But it's probably only worthwhile on Vista or later since XP doesn't seem to use it by default.

But why do you need to replicate the Windows search functionality anyway?


Matty(Posted 2009) [#3]
Because the Windows search facility doesn't seem capable of finding strings within a file that is not an Office file or a text file with an extension other than .txt

Unless I'm mistaken of course.


xlsior(Posted 2009) [#4]
Matty: You're correct, but there is a registry tweak you can do to add additional file extensions to be indexed in full.


Matty(Posted 2009) [#5]
Hi xlsior - do you happen to know where I might find this registry tweak?

EDIT - googled it, found it, yet to install though..a bit wary of these registry things.


_33(Posted 2009) [#6]
grep, or wingrep
http://www.wingrep.com/


Blitzplotter(Posted 2009) [#7]
wow, windows grep(;-)