In the sample code , show below, we are merging many binary file to a single mp3 file. This process works fine for 4 times , but on the 5th time, the application crashes on br.Read without throwing any .net error. We have implemented try catch blocks also.It gives the system error &H80131315&
Dim fsInput As System.IO.FileStream Dim fsOutput As System.IO.FileStream Dim bw As BinaryWriter Dim br As BinaryReader Dim sMergeFiles() As String Dim iCount As Short Dim bytBuffer() As Byte = New Byte() {} Dim lFileSize As Long Dim sMergedFile As String TrysMergeFiles = alsFileToBeMerged
sMergedFile = sOutputFileName
If File.Exists(sMergedFile) Then File.Delete(sMergedFile)fsOutput =
New FileStream(sMergedFile, FileMode.CreateNew, FileAccess.ReadWrite)bw =
New BinaryWriter(fsOutput) For iCount = 0 To sMergeFiles.Length - 1 If sMergeFiles(iCount) <> "" ThenlFileSize = FileSize(sMergeFiles(iCount))
fsInput =
New FileStream(sMergeFiles(iCount), FileMode.Open, FileAccess.Read)br =
New BinaryReader(fsInput)br.BaseStream.Seek(0, SeekOrigin.Begin)
ReDim bytBuffer(lFileSize - 1)br.Read(bytBuffer, 0, bytBuffer.Length)
bw.Write(bytBuffer)
fsOutput.Flush()
br.Close()
fsInput.Close()
Else Exit For End If NextfsOutput.Close()
bw.Close()
Catch FinallyfsOutput =
Nothingbw =
Nothingbr =
NothingfsInput =
Nothing End Try

.NET Application crashes
Jimski
snamburu
Hello,
Do you use BinaryReader's PeekChar() or ReadChar() methods anywhere in your code The surrogate description on the exception is usually generated when these methods are used. Is it possible to get a small repro for the problem pl.
Thanks
Lakshan Fernando
BCL Team
Visual Martin
Hi Philippe Dufour,
We have a put a messagebox in the catch block. The application run fine 4 times, and on the 5th occasion , the application crashes without showing any messagebox.
Bojidar Markov
buzzbuba
Could you paste the exception message you get when you put the MessageBox in the catch statement
I'm sure it would help us find the problem you have with br.Read
Arnak
Arunachalam
elygp
Hi Philippe Dufour,
Thanks for your reply. We are reading binary file, so when I tried your code,it gave error
Additional information: Found a low surrogate char without a preceding high surrogate at index: 223. The input may not be in this encoding, or may not contain valid Unicode (UTF-16) characters.
Jens Sauer
Just tried your code.
Works fine here, no exception, nothing.
The only change I did was with the FileSize function. I had to use FileLen (didn't find in which assembly, .Net 1.1, to find it).
Just a little comment, you could also use the StreamReader / StreamWriter for your code.
Public
Sub TransfererDonnees(ByVal FileNames As ArrayList, ByVal ExitFile As String)Dim
sRead As StreamReaderDim sWrite As New StreamWriter(ExitFile) Dim Ligne As String
Dim Counter As Integer While Compteur < FileNames.Count
sRead = New StreamReader(CType(FileNames(Counter), String))
Ligne = sRead.ReadToEnd()
sWrite.WriteLine(Ligne)
sRead.Close()
End WhileCompteur += 1
sWrite.Close()
Richard Moorhouse