Jump to content
  • Advertisement
Sign in to follow this  
ginkeq

ReadByte C# Problem

This topic is 4010 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

If I am using ReadByte and PeekChar, and I know the file has 0xFF in it, how can I read this in? PeekChar doesnt distinguish between a file with 0xFF and what is really the end of the stream.

Share this post


Link to post
Share on other sites
Advertisement
PeekChar will return -1 as an int at the end of the file, not 0xFF - if you're just casting to a byte then you will have problems.

Of course, you can check manually if you're at the end of a stream by comparing the BinaryReader.BaseStream.Position against BinaryReader.BaseStream.Length.

I'm not really sure why you're mixing and matching ReadByte and PeekChar, though...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!