Checking occurances in a txt/ini file

A

Adam Honek

In VB.Net is there a simple quick way to check how many
occurances of a phrase (ie "xxx") there is in a txt or ini file
or must we do it the long fashioned way of reading through
the entire file one line at a time?

Thanks,
Adam
 
C

Cerebrus

You don't have the read the entire file one line at a time, but you
could read it in one go, using the ReadToEnd() method.

Then you could call the IndexOf method in a loop, and increment the
start position of this method with each iteration.

Is that too Long-fashioned ?

Regards,

Cerebrus.
 
H

Herfried K. Wagner [MVP]

Cerebrus said:
You don't have the read the entire file one line at a time, but you
could read it in one go, using the ReadToEnd() method.

True, but I'd only do that for small files...
 

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

Similar Threads


Top