I
IGW
I am getting a "conversion buffer overflow" in PeekChar
method of a BinaryReader.
(I am using C++, VS .NET 2003).
Always seems to be in the same place in any given file but
the location of the error varies according to the file.
I know that I can do the read in a try catch and/or other
things to solve the issue - that is not the point.
PeekChar should work.
Any ideas,
Ian
Code in question looks like (button handler and the word
wrap may not be ideal):
private: System::Void btnGo_Click(System::Object *
sender, System::EventArgs * e)
{
FileStream * fIn;
FileStream * fOut;
BinaryReader * In;
BinaryWriter * Out;
unsigned char CurrentByte;
if(File::Exists(tbInFile->Text))
{
fIn = new FileStream(tbInFile->Text,
FileMode::Open);
fOut = new FileStream(tbFileOut->Text,
FileMode::Create);
In = new BinaryReader(fIn);
Out = new BinaryWriter(fOut);
while (In->PeekChar() != -1) // bombs here
{
CurrentByte = In->ReadByte();
// do stuff here
// ...
Out->Write(CurrentByte);
// while debugging PeekChar issue
// flush byte by byte
Out->Flush();
}
Out->Flush();
Out->Close();
In->Close();
fIn->Close();
fOut->Close();
}
}
};
method of a BinaryReader.
(I am using C++, VS .NET 2003).
Always seems to be in the same place in any given file but
the location of the error varies according to the file.
I know that I can do the read in a try catch and/or other
things to solve the issue - that is not the point.
PeekChar should work.
Any ideas,
Ian
Code in question looks like (button handler and the word
wrap may not be ideal):
private: System::Void btnGo_Click(System::Object *
sender, System::EventArgs * e)
{
FileStream * fIn;
FileStream * fOut;
BinaryReader * In;
BinaryWriter * Out;
unsigned char CurrentByte;
if(File::Exists(tbInFile->Text))
{
fIn = new FileStream(tbInFile->Text,
FileMode::Open);
fOut = new FileStream(tbFileOut->Text,
FileMode::Create);
In = new BinaryReader(fIn);
Out = new BinaryWriter(fOut);
while (In->PeekChar() != -1) // bombs here
{
CurrentByte = In->ReadByte();
// do stuff here
// ...
Out->Write(CurrentByte);
// while debugging PeekChar issue
// flush byte by byte
Out->Flush();
}
Out->Flush();
Out->Close();
In->Close();
fIn->Close();
fOut->Close();
}
}
};