My C# program is running well on my computer and the sound is playing, but when i sent it to my lecturer, he said the program was running but it couldn't locate my sound file. my file location in the program was like:
C:\Documents\Visual Studio 2012\Projects\Barista3000_Aroka_Lab6\Barista3000_skal\Sounds\sound.wav
How do i make sure the sound will always be located when ran on a different computer?
You need to add the file to your project like and set build action to content.

And when you build the project it will end up in your output folder, just play it with something like.
PlayFile("sound.wav"); // I made up this method btw.
Notice, not the full path to the file, this is relative and it will look for this file in the working (current) folder.
How do i make sure the sound will always be located when ran on a different computer?
For this, you will still need to distribute it with your EXE and other 'stuff' that's in your build output folder.
Also, have a look at embedding resources, that way you can include the WAV in your EXE.
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