How to play a sound in C#, .NET

Viewed 283265

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

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

7 Answers

I think you must firstly add a .wav file to Resources. For example you have sound file named Sound.wav. After you added the Sound.wav file to Resources, you can use this code:

System.Media.SoundPlayer player = new System.Media.SoundPlayer(Properties.Resources.Sound);
player.Play();

This is another way to play sound.

Related