Because of the under the hood buffering strategy of BinaryReader, it is unclear to me whether is it ok or not to read an offset stored in a stream, then reposition the strea
I would say that it is not always safe (although it might be safe in some cases).
The Microsoft documentation for BinaryReader.BaseStream explicitly states:
Using the underlying stream while reading or while using the BinaryReader can cause data loss and corruption. For example, the same bytes might be read more than once, bytes might be skipped, or character reading might become unpredictable.
So I would avoid it.
(Interestingly, there's a BinaryWriter.Seek()
method, but no BinaryReader.Seek()
.)