Germcloud
Member
- Joined
- Jun 6, 2010
- Messages
- 9
- Programming Experience
- 1-3
An application I'm building requires that I save a wav resource to a wav file on disk. I can do it just fine for mp3's, but when I try to save the wav resources I get "Error 1 Value of type 'System.IO.UnmanagedMemoryStream' cannot be converted to '1-dimensional array of Byte'."
The program needs to save both kinds of resources, mp3's and wav to a file on disk. This is what I have so far:
And this is the call that's made to the class above:
flashbulb is the wav resource I'm trying to save. flashbulb.wav
The program needs to save both kinds of resources, mp3's and wav to a file on disk. This is what I have so far:
VB.NET:
Public Function Add(ByRef sndResource As Byte(), ByVal blnPlay As Boolean) As Boolean
'Add one to the count
intTotal += 1
'Save the filename location
strFileName = (Application.StartupPath & "\" & "sound_" & intTotal.ToString & ".wav")
'Create a file from the resource
Try
System.IO.File.WriteAllBytes(Application.StartupPath & "\" & "sound_" & intTotal.ToString & ".wav", sndResource)
Catch ex As Exception
'Show error message
MsgBox(ex.Message)
'Return false and exit function
Return False
Exit Function
End Try
'Assign the audio file
Sound = New Audio(strFileName, blnPlay)
End Function
And this is the call that's made to the class above:
VB.NET:
Music.Add(My.Resources.flashbulb, True)
flashbulb is the wav resource I'm trying to save. flashbulb.wav