Hi.
Thanks for the post. I am trying a new approach using the .CopyTo method
of an array. I have two wav files I am trying to combine into a single
wav file called test.wav. The below code executes with no errors,
however, it only saves the first file into test.wav and not the second
one even though the code appears to be resizing correctly and saving the
byte array from the second file correctly. Can anyone help here? Why is
only the first file being saved to the test.wav file and not the second
one?
BTW the path to the files is stored in web.config and is correct.
Code follows:
' get binary data in file stream
fs = New
FileStream(Server.MapPath(CType(System.Configurati on.ConfigurationSettin
gs.AppSettings.GetValues("PathToSounds")(0), String) & "capital.wav"),
FileMode.Open)
' how large is file ?
intFileSize = fs.Length - 1
' resize array
ReDim SourceFile(intFileSize)
' copy data to byte array now
fs.Read(SourceFile, 0, SourceFile.Length)
' now save this to Completed file array
fs.Close()
ReDim Preserve CompletedFile(SourceFile.Length)
SourceFile.CopyTo(CompletedFile, 0)
' now copy the byte data for the letter
fs = New
FileStream(Server.MapPath(CType(System.Configurati on.ConfigurationSettin
gs.AppSettings.GetValues("PathToSounds")(0), String) & strLetter &
".wav"), FileMode.Open)
intFileSize = fs.Length - 1
' resize array
ReDim SourceFile(intFileSize)
' copy data to byte array now
fs.Read(SourceFile, 0, SourceFile.Length)
fs.Close()
Dim intSavedSpot = CompletedFile.Length - 1
ReDim Preserve CompletedFile(intSavedSpot +
SourceFile.Length)
SourceFile.CopyTo(CompletedFile, intSavedSpot)
' now save the file
fs = New
FileStream(Server.MapPath(CType(System.Configurati on.ConfigurationSettin
gs.AppSettings.GetValues("PathToSounds")(0), String) & "test.wav"),
FileMode.CreateNew)
fs.Position = 0
fs.Write(CompletedFile, 0, CompletedFile.Length)
fs.Close()
Regards,
Justin
*** Sent via Developersdex
http://www.developersdex.com ***