I dont know why I get this error. I simply want to read every byte of a binary file. I just declared a BinaryReader variable:
VB Code:
Dim strmSrc As FileStream = New IO.FileStream("c:\a.exe", FileMode.Open) Dim brSrc As New BinaryReader(strmSrc) [color=red] Do While brSrc.PeekChar <> -1[/color] brSrc.ReadByte() Loop
if the file is small it works fine (like 10 KB) but when I test it with bigger files (200KB) it gives me this error:
An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll
Additional information: Conversion buffer overflow.
and the error happens on the red line, because of brSrc.PeekChar call. I don't understand why calling that could cause a problem. What am I doing wrong? I just want to read all the bytes in the file (this is just a sample code of course)




)
Reply With Quote