How can I play a WAV audio file in from my project\'s Resources? My project is a Windows Forms application in C#.
When you have to add sounds into your project, you will do so by playing .wav file(s). Then you have to add the .wav file(s) like this.
using System.Media; //write this at the top of the code
SoundPlayer my_wave_file = new SoundPlayer("F:/SOund wave file/airplanefly.wav");
my_wave_file.PlaySync(); // PlaySync means that once sound start then no other activity if form will occur untill sound goes to finish
Remember that you have to write the path of the file with forward slashes (/) format, don't use back slashes (\) when giving a path to the file, else you will get an error.
Also note, if you want other things to happen while the sound is playing, you can change my_wave_file.PlaySync(); with my_wave_file.PlayAsync();.