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 toread 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 andits 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