Solved

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

Posted on 2008-06-22
7
317 Views
Last Modified: 2013-11-07
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?
0
Comment
Question by:runbird
7 Comments
 
LVL 3

Expert Comment

by:dshroutait
ID: 21843206
You could use Notepad++
0
 
LVL 2

Expert Comment

by:ayus80
ID: 21843222
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 21843223
have you tried to open it with Visual Studio?
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 21843234
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
 
LVL 2

Accepted Solution

by:
martin_kongen earned 500 total points
ID: 21892602
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now