How to play a sound in C#, .NET

Khilen Maniyar picture Khilen Maniyar · Aug 17, 2010 · Viewed 231.5k times · Source

I have a Windows application written in C#/.NET.

How can I play a specific sound when a button is clicked?

Answer

bporter picture bporter · Aug 17, 2010

You could use:

System.Media.SoundPlayer player = new System.Media.SoundPlayer(@"c:\mywavfile.wav");
player.Play();