L
lord.zoltar
Hi, I'm having some trouble with a StreamReader.
I use a System.IO.StreamReader to read a text file and then print it.
If the user has selected a range of pages starting past the first page,
I have to make the StreamReader jump to some point in the file.
To make the StreamReader jump to where it should be, I use the
following code:
fReader.BaseStream.Seek(fileBookmark + (Me.reportTextWidth *
linesPerPage * startPage), IO.SeekOrigin.Begin)
I've run this through the debugger, and the expression "fileBookmark +
(Me.reportTextWidth * linesPerPage * startPage)" seems to be
calculating the starting character correctly.
When I start reading the file, I use:
line = fReader.ReadLine()
....and this is where the problems occur!! I set a watch in the
debugger on fReader.BaseStream.Position. After the first operation (the
seek, shown above), fReader.BaseStream.Position is 2479. After the
ReadLine executes, fReader.BaseStream.Position is 3503, it has
increased by 1,024 Bytes! For all subsequent ReadLines,
fReader.BaseStream.Position does not change at all. Maybe I'm just not
quite understanding how the VB.NET StreamReader works... Does anyone
have an idea why this would be happening? Or maybe a better way to do
what I'm trying to do:
Jump to a position in a text file and read!
I use a System.IO.StreamReader to read a text file and then print it.
If the user has selected a range of pages starting past the first page,
I have to make the StreamReader jump to some point in the file.
To make the StreamReader jump to where it should be, I use the
following code:
fReader.BaseStream.Seek(fileBookmark + (Me.reportTextWidth *
linesPerPage * startPage), IO.SeekOrigin.Begin)
I've run this through the debugger, and the expression "fileBookmark +
(Me.reportTextWidth * linesPerPage * startPage)" seems to be
calculating the starting character correctly.
When I start reading the file, I use:
line = fReader.ReadLine()
....and this is where the problems occur!! I set a watch in the
debugger on fReader.BaseStream.Position. After the first operation (the
seek, shown above), fReader.BaseStream.Position is 2479. After the
ReadLine executes, fReader.BaseStream.Position is 3503, it has
increased by 1,024 Bytes! For all subsequent ReadLines,
fReader.BaseStream.Position does not change at all. Maybe I'm just not
quite understanding how the VB.NET StreamReader works... Does anyone
have an idea why this would be happening? Or maybe a better way to do
what I'm trying to do:
Jump to a position in a text file and read!