Hi,
I'm having FileStream.Writ e behave rather oddly.
The code below should take file a.txt and append it to file b.txt :
I test with :
a.txt "abc"
b.txt "<This is the Orig>"
Now when I run this code, the characters in a.txt are read correctly to buffer, but the file b.txt contains :
"<This is the Orig>扡c"
What on earth is going on ???
cheers
I'm having FileStream.Writ e behave rather oddly.
The code below should take file a.txt and append it to file b.txt :
Code:
Dim buffer As Byte()
Dim bytesRead As Integer
Dim fStreamIN As New FileStream("c:\a.txt", FileMode.Open, FileAccess.Read)
Dim fStreamOUT As New FileStream("c:\b.txt", FileMode.Append, FileAccess.Write)
ReDim buffer(fStreamIN.Length)
bytesRead = fStreamIN.Read(buffer, 0, fStreamIN.Length)
MsgBox("Read bytes:" + Str(bytesRead) + " Expected:" + Str(fStreamIN.Length))
MsgBox("byte 1:" + Chr(buffer(0)) + vbCrLf + _
"byte 2:" + Chr(buffer(1)) + vbCrLf + _
"byte 3:" + Chr(buffer(2)) + vbCrLf)
fStreamOUT.Write(buffer, 0, buffer.Length)
fStreamOUT.Flush()
fStreamIN.Close()
fStreamOUT.Close()
a.txt "abc"
b.txt "<This is the Orig>"
Now when I run this code, the characters in a.txt are read correctly to buffer, but the file b.txt contains :
"<This is the Orig>扡c"
What on earth is going on ???
cheers
Comment