I have some problems with relative paths and reproduction of wav files. I have this simple code which works perfectly:
SoundPlayer player = new SoundPlayer();
player.SoundLocation = @"C:\Users\Admin\Documents\Visual Studio 2012\Projects\TestProject\TestProject\Data\Sounds\car.wav";
player.Play();
I want somehow to play that file with relative path but I didn't have success with this:
SoundPlayer player = new SoundPlayer();
player.SoundLocation = @"Data\Sounds\car.wav";
player.Play();
Thank you!
Is Data
directory in the root directory of your application? Are you copying the directory contents as output?
If so, did you mean, Data\Sounds\car.wav
?
Which, if running from Visual Studio would be in [projectroot]\[release]\bin\Data\Sounds\car.wav
If you don't see this directory in your bin folder, you'll need to ensure you're selecting all of the files you want copied to your output directory (which will copy the directory structure). You can do this by clicking on the file in your project and selecting the file as output.
Get the full path of your file with Path.GetFullPath("relativ/path")
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