Yes I know, and I'm terribly sorry that I've took so long to write the continuation of that blog-post. Nevertheless, here it is.
But at first I'd like to sum up the results of the last post:
- StreamReader is not the right choice for this task.
- Seeking does not work.
- The index is completely useless and contains wrong data.
class FacadeReaderThat few lines would be enough to make the application run. It is fairly fast and has the big advantage that it's simple to implement (no need to cope with all the low level stuff). Amazing, isn't it?
An internal position marker, as well as a real FileStream and
Read the next Line from the StreamReader and then add the
byte-count of the new line + the line feed character(s) to the
internal position marker
Seek on the underlying stream, call
StreamReader.DiscardBufferedData() and last but not least store
the given position at this.position.
Oh, I almost forgot: Happy Christmas everybody! :-)
1 Or is this a decorator, am unsure about this.