Search code examples
c#.netaudio

How to play a sound in C#, .NET


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

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


Solution

  • You could use:

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

    The class System.Media.SoundPlayer is available from a nuget package System.Windows.Extensions