Hello
I am reading data from binary file ,some of this
data is string and some is images
and the length of some of this data is saved in many places in the file
I need a way to move back in the file
i use the Seek method with the StreamReader to do that when i read text files
but there is no Seek method for the BinaryReader
Any body can help me .

Moving in Binary File
kamisama
I try to read the file and every thing is good
until the BinarReader Position property = 34024
in this position an exception raised
and the this message box shown :
---------------------------
---------------------------
The output char buffer is too small to contain the decoded characters, encoding 'Unicode (UTF-8)' fallback 'System.Text.DecoderReplacementFallback'.
Parameter name: chars
---------------------------
OK
---------------------------
Can you tell me what is the wrong
Thank you
BG22
Yes
when i use (char) BinaryReader.ReadByte
the program work
while when i use BinaryReader.ReadChar
an exception is raised
prabashmi
Isabella.Lee
I try to use the BinaryReader ReadByte Method
to read and it work so good
Is there any different between ReadByte and ReadChar Methods for the
BinarySteam
ErikJakob
thank you
That is what i look for
djjay0131
int i = reader.ReadInt32();
reader.BaseStream.Seek(-sizeof(Int32), System.IO.SeekOrigin.Current);
i = reader.ReadInt32();
chakira
I have a binary file , this file hold data about cheques
this data consist of char data like cheque number and binary data
like cheque image
I tried to read the data using ReadChar method
like this :
BinaryReader binReader;
try
{
binReader = new BinaryReader(File.Open(args[0], FileMode.Open));
}
catch (FileNotFoundException exc)
{
MessageBox.Show(exc.Message);
return;
}
catch (IndexOutOfRangeException exc)
{
MessageBox.Show(exc.Message + "\nUsage: ShowFile File");
return;
}
do
{
try
{
// read the file
binReader.ReadChar();
}
} while (binReader.BaseStream.Position !=(binReader.BaseStream.Length-1));
but a exception is raised and its message :
---------------------------
---------------------------
The output char buffer is too small to contain the decoded characters, encoding 'Unicode (UTF-8)' fallback 'System.Text.DecoderReplacementFallback'.
Parameter name: chars
---------------------------
OK
---------------------------
I try
(char)binReader.ReadByte();
istead of
binReader.ReadChar();
and it is work
I want to know why this happen
is there any different between the to methods in the way
to read the file
DennisLonndon