I'm concatenating data files, but the problem is that I'm seeing some extra bytes where the files are joined. The new file has extra bytes. I had thought this was maybe a problem with encoding.
Here are the methods that I've tried to use to concatenate the files. The first example I'm getting extra 0xA0 0x00 bytes.
Dim inputfiles() As String = Directory.GetFiles(sourcedir, pattern)
Dim bufSize As Integer = 1024 * 64
Dim buf As Byte() = New Byte(bufSize) {}
For Each inputfile As String In inputfiles
Using fs As New FileStream(inputfile, FileMode.Open, FileAccess.Read)
Dim arrfile() As Byte = New Byte(fs.Length) {}
fs.Read(arrfile, 0, arrfile.Length)
fs.Close()
Using fo As New FileStream(outfilename, FileMode.Append, FileAccess.Write)
Using bw As New BinaryWriter(fo)
bw.Write(arrfile, 0, arrfile.Length)
bw.Close()
fo.Close()
End Using
End Using
End Using
Next
And the second I get only the 0xA0 byte.
For Each inputfile As String In inputfiles
Using fs As New FileStream(inputfile, FileMode.Open, FileAccess.Read)
Using sr As New StreamReader(fs, Encoding.ASCII)
While Not sr.EndOfStream
Using fo As New FileStream(outfilename, FileMode.Append, FileAccess.Write)
Using sw As New StreamWriter(fo, Encoding.ASCII)
sw.Write(sr.ReadToEnd)
sw.Close()
fo.Close()
End Using
End Using
End While
End Using
End Using
Next
Thanks for the help in advance.