How to efficiently find a string in multiple text files?

  • Thread starter Thread starter Buddhist[CHinA]
  • Start date Start date
B

Buddhist[CHinA]

The text files are not only the .txt files, but also all ascii files.

Thx.
 
Buddhist,

For me a txt file is the same as an ascii file. (a classic name for a text
file)

Therefore can you make it more clear for us what you mean by this.

Be aware that finding strings in compressed or hassled files is not as easy
to do as in a txt file.

Cor
 
O, what I described was a little confusing and didn't make sense.

Actually, I want to ask how to searh a string in lots of text files quickly.
I implemented this by using System.IO(directory and file), read each line
and checked whether there was string desired, then recorded line numbers.
But its performance is very low, especially while processing lots of files.
So I am doubting whether directly using System.IO can meet my performance
requirement. Do I need to do many optimization by myself? And how?

Thx.
 
Buddhist,
O, what I described was a little confusing and didn't make sense.

Actually, I want to ask how to searh a string in lots of text files
quickly.
I implemented this by using System.IO(directory and file), read each line
and checked whether there was string desired, then recorded line numbers.
But its performance is very low, especially while processing lots of
files.
So I am doubting whether directly using System.IO can meet my performance
requirement. Do I need to do many optimization by myself? And how?
That is in fact the only method I know as well, you can probably slightly
improve it by doing some multithreading with ony two threads, not more
(where the advantage is so low that I would not do it). (Finding the string
in an array can than be done seperated from retrieving the array).
Mutltithreading to read more files is without any sense and slows only your
application.

Have as well a look to this message from Jon some days ago.

http://groups.google.com/group/microsoft.public.dotnet.general/msg/eba149199c66b64bI hope this helps,Cor
 
Thx your help.

But I am dubious about the example by Jon.
Is checking each char in a huge char array very fast?
I'm afraid not.

Or there is sth I haven't understood.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top