Hi Chris,
You may be looking for BinaryReader.PeekChar()
It will return the integer value of the next character.
To force it to return the next byte instead of character
use the overloaded BinaryReader constructor specifying an
8-bit text encoding (for instance "ISO-8859-1").
On Mon, 10 Jan 2005 10:10:47 +0100, Chris <(E-Mail Removed)> wrote:
> Hi,
>
> What is the most easy way to check on EOF while reading a
> binary file with all integers ?
>
> In lot of examples the read data are first stored in a
> string, and afterwards the string is checked on *null*
> value, but that does not work for binary files.
>
> Like this ...
> string buf;
> while ( (buf = file.ReadString()) != null)
> {
> (...)
> }
>
> I need something like
> int tim;
> while ( (tim = file.ReadSingle()) != null)
> {
> (...)
> }
> but that does not work, as *tim* is an integer, and cant be
> checked on *null*.
>
> Is there a separate function (so, not getting any data) in
> C# for merely checking the end-of-file condition ?
>
> Thanks,
> Chris.
>
--
Happy Coding!
Morten Wennevik [C# MVP]
|