So I've made a small text-based game in C# but I'd like some music to it, I have tried this:
System.Media.SoundPlayer player = new System.Media.SoundPlayer();
player.SoundLocation = "c:\PathToMusic\..music.wav";
player.Play();
Which worked, but when I build my application to a .exe file it's not included so when the other person does not have that specific sound in the specific folder it won't work.
I have added the file to my Solution Explorer but have no idea what that file location is called.
Try this solution :
Project -> Add Existing Item... -> Add your .wav file.
Copy always
Copy to Output Directory
to Copy always
.Build Action
to Content
.This will make Visual Studio always copying the music file into the output directory (e.g. Debug folder).
using System.Media;
SoundPlayer player = new SoundPlayer();
player.SoundLocation = AppDomain.CurrentDomain.BaseDirectory + "\\yourmusic.wav";
player.Play();