Hi,
I'm experiencing some problem with the following code:
st = File.Open(sFilename, FileMode.Open, FileAccess.ReadWrite)
br = New BinaryReader(st)
Do Until br.PeekChar = -1
Dim buffer() As Byte = br.ReadBytes(1024)
...
Loop
Basically, PeekChar would sometimes cause the System.ArgumentException in
mscorlib.dll with the message "Conversion buffer overflow." However, when I
examine the value after inserting breakpoints, br.PeekChar returns normal
values without error. Furthermore, the number of bytes read before the
error occurs is always the same, assuming I am using the same file.
This problem disappears after I change the code to the following:
Dim len As Integer = 1
Do Until len = 0
Dim buffer(1024) As Byte
len = br.Read(buffer, 0, 1024)
...
Loop
This makes me believe that the problem _is_ indeed caused by PeekChar.
I've tried searching for people expericing similar problems online, but to
no avail. Anyone has any idea?
Thanks.
Tim