I'm trying to add a notification alarm when a user presses a button
private void button1_Click(object sender, EventArgs e)
{
SoundPlayer simpleSound = new SoundPlayer(@"C:\Users\.........\ambbrdg7.wav");
simpleSound.Play();
}
I want to add the ambbrdg7.wav to my exe file to make sure my program always has access to this file
Project + Properties, Resources tab, click on the arrow on the "Add Resource" button and select your .wav file. Then it is simply:
var player = new System.Media.SoundPlayer();
player.Stream = Properties.Resources.tada;
player.Play();
where "tada.wav" was the resource I added, change it to your resource name.
You either want to add the file as Content (add the file to your project and set it as Build Action -> Content) or add it as a resource - see http://msdn.microsoft.com/en-us/library/7k989cfy(v=vs.80).aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With