.net2.0播放WAV文件

// To play a File from a disk locaiton
Dim objPlayer As New SoundPlayer
objPlayer.SoundLocation = "C:\Alert.wav"
objPlayer.Play()

// To play a File from applcation as embedded resouce
Dim objPlayer As New SoundPlayer
objPlayer.Stream = GetEmbeddedResourceStream()
objPlayer.Play()

Protected Function GetEmbeddedResourceStream() As Stream
  Dim objAssembly As System.Reflection.Assembly
  Dim soundstream As Stream
  objAssembly = System.Reflection.Assembly.LoadFrom(Application.ExecutablePath)
  soundstream = objAssembly.GetManifestResourceStream("Alert.wav")
  return soundstream
End Function

你可能感兴趣的:(.net)