Hello
I want to parse a BinaryStream file and change bytes that way:
var Track As UInt8
D81Image.BytePosition = 400128
Do
MainWindow.Console.Value = MainWindow.Console.Value + "Read before: " + D81Image.BytePosition.ToString + EndOfLine
Track = D81Image.ReadUInt8
MainWindow.Console.Value = MainWindow.Console.Value + "Read after: " + D81Image.BytePosition.ToString + EndOfLine
If Track = 0 Then
MainWindow.Console.Value = MainWindow.Console.Value + "Write before: " + D81Image.BytePosition.ToString + EndOfLine
D81Image.WriteUInt8( &hFF )
MainWindow.Console.Value = MainWindow.Console.Value + "Write after: " + D81Image.BytePosition.ToString + EndOfLine
Exit
Else
// Jump over to next sector
D81Image.BytePosition = D81Image.BytePosition + 255
End If
Loop Until D81Image.BytePosition >= 409600
The output to the console is this:
Read before: 400128
Read after: 400129
Read before: 400384
Read after: 400385
Write before: 400385
Write after: 404481
In second loop iteration the code Track is 0 and heads to “D81Image.WriteUInt8( &hFF )”. The weird thing: Before writing the BytePosition is at 400385 (correct) but after writing a single byte the BytePosition is set to BytePosition 404481 instead of expected 400386. Either there is a bug or I am missing something trivial.
Any ideas about this?