When I write:
var tagType = _reader.ReadByte();
while (tagType != 8)
{
var skip = ReadNext3Bytes() + 11;
_reader.BaseStream.Position += skip;
tagType = _reader.ReadByte();
}
...it's working, but when I write:
var tagType = _reader.ReadByte();
while (tagType != 8)
{
_reader.BaseStream.Position += ReadNext3Bytes() + 11;
tagType = _reader.ReadByte();
}
...it is not working, and I can't understand why - I'm getting unexpected results. Heres the ReadNext3Bytes
method:
private long ReadNext3Bytes()
{
try
{
return Math.Abs((_reader.ReadByte() & 0xFF) * 256 * 256 + (_reader.ReadByte() & 0xFF)
* 256 + (_reader.ReadByte() & 0xFF));
}
catch
{
return 0;
}
}
Why is that, and how can I fix it?
Thanks.