Home All Groups Group Topic Archive Search About

Checking occurances in a txt/ini file

Author
17 Apr 2006 11:59 PM
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

Author
18 Apr 2006 5:53 AM
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.
Author
18 Apr 2006 10:36 AM
Herfried K. Wagner [MVP]
"Cerebrus" <zorg***@sify.com> schrieb:
> 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...

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>