I know that there is a way to make a for loop work like a while loop.
I have this code working :
while (BR.BaseStream.Position < BR.BaseStream.Length) // BR = BinaryReader
{
int BlockLength = BR.ReadInt32();
byte[] Content = BR.ReadBytes(BlockLength);
}
I need the for equivalent for this while loop..
So Far, I have this :
for (long Position = BR.BaseStream.Position; Position < BR.BaseStream.Length; //Don't Know This)
{
int BlockLength = BR.ReadInt32();
byte[] Content = BR.ReadBytes(BlockLength);
}
Every time you use one of the Read methods, the BinaryReader increments it’s position, so you don’t actually need anything in that section.
Update: I just realized that the
Positionvariable isn’t ever getting updated. You could either update it at the end of the for loop or in the third section. I updated the code to updatePositionin the third section of the for loop.