Solved

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

Posted on 2008-06-22
7
332 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 3

Expert Comment

by:dshroutait
ID: 21843206
You could use Notepad++
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…

729 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