Hi.
I am tring to read from random parts of an SDF file using a stream
reader. I know each line in my file is 30 chars long so I know where in
the file I want to go to read a specific record.
The first seek works fine. But due to buffering (from what I've read)
the second seek will not point to the start of the file and will be
positioned just 30 bytes after the first seek. Is there any way I can
avoid the buffering or is there another solution that would allow me to
read from any part of a text file?
Any help/advice would be great.
My code.
Dim bytes(29) As Char
Dim bytes2(29) As Char
Dim fs As New FileStream("h:\address_procV1\names.sdf", fileMode.Open,
FileAccess.Read)
' Create a character reader.
Dim sr As New StreamReader(fs)
sr.BaseStream.Seek(21657360, SeekOrigin.Begin)
'''sr.ReadBlock(bytes2, 0, 30)
sr.Read(bytes, 0, 30)
sr.BaseStream.Seek(0, SeekOrigin.Begin)
'''sr.ReadBlock(bytes2, 0, 30)
sr.Read(bytes2, 0, 30)