您可能应该将其放入案例陈述中
Dim ResourceFilePathPrefix As String
If System.Diagnostics.Debugger.IsAttached() Then
'In Debugging mode
ResourceFilePathPrefix = System.IO.Path.GetFullPath(Application.StartupPath & "\..\..\resources\")
Else
'In Published mode
ResourceFilePathPrefix = Application.StartupPath & "\resources\"
End If
'you name your files Fire.wav, Water.wav or whatever you want.
playerStream = ResourceFilePathPrefix & textBox1.text + ".wav"
My.Computer.Audio.Play(playerStream, AudioPlayMode.Background)
或者您可以直接引用它:
Try
My.Computer.Audio.Play("C:\TEST\" & textBox1.text,AudioPlayMode.Background)
Catch ex As Exception
MsgBox("The file does not exist." & ex.Message, MsgBoxStyle.Critical)
End Try
假设您的 wav 文件是 @ c:\test :)