How to open a huge text file and count the lines?

I am using ASP.NET in VB.
I have some huge text file which the size is normally 950MB to 1GB. I need to do the counting of lines for my text file. And this huge file is located at my local computer.
May I know is there any solution that I can do the count of lines for my text file?
runbirdAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
martin_kongenConnect With a Mentor Commented:
You want to count the lines automatically, when a user requests the web page, right? You should probably open the file using System.IO.StreamReader, StringReader or TextReader. (I can never remember which one to use).

Then you can use that stream and loop through every character in the file. Your counter starts at 1, and you add 1 every time you encounter the newline character (probably called vbLF in visual basic). When done, the counter has the number of lines and you can close the file.
0
 
dshroutaitCommented:
You could use Notepad++
0
 
Jaime OlivaresSoftware ArchitectCommented:
have you tried to open it with Visual Studio?
0
 
Jaime OlivaresSoftware ArchitectCommented:
or you can use some kind of line counter, you don't have to load the file into memory:
 http://www.codeproject.com/KB/files/SourceCodeLineCounter.aspx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.