This example plays a sound at a given path at run time.
Sub PlaySimpleSound()
My.Computer.Audio.Play("c:\Windows\Media\chimes.wav")
End Sub
private void playSimpleSound()
{
SoundPlayer simpleSound = new SoundPlayer(@"c:\Windows\Media\chimes.wav");
simpleSound.Play();
}
This example requires:
File operations should be enclosed within appropriate structured exception handling blocks.
The following conditions may cause an exception:
Do not make decisions about the contents of the file based on the name of the file. For example, the file Form1.vb may not be a Visual Basic source file. Verify all inputs before using the data in your application.
Tasks
Reference
Other Resources