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:
  1. Dim strmSrc As FileStream = New IO.FileStream("c:\a.exe", FileMode.Open)
  2.         Dim brSrc As New BinaryReader(strmSrc)
  3.  
  4.      [color=red]   Do While brSrc.PeekChar <> -1[/color]
  5.             brSrc.ReadByte()
  6.         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 )