Re: How to search files for text string most efficiently?

From: Richard Jalbert (richmann_at_sympatico.ca)
Date: 10/28/04


Date: Thu, 28 Oct 2004 17:45:51 GMT

On Thu, 28 Oct 2004 12:24:54 -0500, "Jim" <jr@nospam.wi.rr.com> wrote:

>Hello,
>
>I am working on a small windows application for a client, and as one of the
>functions they want a search that will let them enter a search string, then
>search a directory for all flies that contain that search string AND display
>the lines that contain the search string.
>
>They have windows ME, XP and 2000 systems.
>
>Does anyone have any ideas as to the most efficient way to do this?
>
>Also, if multiple directories are chosen, should threads be used for the
>search operation?
>
>Thanks!

Personnaly I would do it this way:

Each directory would be queried so as to load all filenames in one
array (I've never done that part so...)

Then using that array, get each filename, get and read by OPEN AS
BINARY each file, loading its content in a single one string buffer,
sized after getting the file size. on which you could do a "instr"
function.

Error checking would be needed all the way through.
**********************************************************************
Richard Jalbert Programmer-Analyst Richmann@sympatico.ca

Dogs have owners, cats have staff.

http://www3.sympatico.ca/richmann/
**********************************************************************



Relevant Pages

  • Re: FileListBox
    ... Try Step -1 to go backwards through the list, collection, array, etc... ... the user specifies a search string to ... > find in the filenames along with the string to replace it with. ... > on this, I want to cycle through a FileListBox, looking at each ...
    (microsoft.public.vb.general.discussion)
  • Best approach?
    ... I've written a function that parses a search string and returns a 1D array ... search terms are entered. ...
    (microsoft.public.fox.programmer.exchange)
  • Re: Tracking key combination
    ... > charactes typed by the user? ... array, make the counter wrap around to the start of the array when it ... Suppose we are looking for the string ABCDE, and the user types xyABCDE: ... (our array is the same size as the search string, ...
    (comp.lang.java)
  • FileListBox
    ... the user specifies a search string to ... find in the filenames along with the string to replace it with. ... on this, I want to cycle through a FileListBox, looking at each ...
    (microsoft.public.vb.general.discussion)
  • Re: FileListBox
    ... the user specifies a search string to ... > find in the filenames along with the string to replace it with. ... > on this, I want to cycle through a FileListBox, looking at each ... > I'm having a problem figuring out how to cycle through the file list. ...
    (microsoft.public.vb.general.discussion)