1 GB text file

  • Thread starter Thread starter Patrick Sannes
  • Start date Start date
P

Patrick Sannes

Hello,

I want to read an 1GB text file in parts of 100 lines. When I use just a
simple stram/filereader, I think it reads the whole file, wich results in a
hanging machine. Is there a way to do it in blocks? For debugging this is a
lot easyer.

Patrick
 
Patrick said:
Hello,

I want to read an 1GB text file in parts of 100 lines. When I use just a
simple stram/filereader, I think it reads the whole file, wich results in a
hanging machine. Is there a way to do it in blocks? For debugging this is a
lot easyer.

Patrick

I've used StreamReader.ReadLine() on 100+ MB files just fine, and it didn't
read the whole file, just that line.
 
I've used StreamReader.ReadLine() on 100+ MB files just fine, and it
didn't
read the whole file, just that line.

You tried something like:
StreamReader sr = File.OpenText(filename);
String input = sr.ReadLine();

??
 
Patrick Sannes said:
I want to read an 1GB text file in parts of 100 lines. When I use just a
simple stram/filereader, I think it reads the whole file, wich results in a
hanging machine. Is there a way to do it in blocks? For debugging this is a
lot easyer.

How are you reading it? If you use TextReader.ReadToEnd it will indeed
read the whole file. If you just use ReadLine it will only read a line
at a time.
 
Back
Top