Home Ask Login Register

Developers Planet

Your answer is one click away!

Intensivist February 2016

How do I create a URI string that correctly points to a .wav file in my Resource directory?

I need to play a sound byte (MP3 or wav) from within a WPF application. I would like to use the MediaPlayer. I have a .wav file with; "Build Action" = Content and "Copy to Output Directory" = "Copy if Newer" and this file is located in the Resources directory of my app.

However, I just cant get the URI string right. (and maybe the Build Action is not correct)


Intensivist February 2016

I found this from Tolga Evcimen and it does work:

how to get relative path

var outPutDirectory = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase); var SoundBytePath = System.IO.Path.Combine(outPutDirectory, "Resources\SoundByte.wav");

Post Status

Asked in February 2016
Viewed 2,737 times
Voted 12
Answered 1 times


Leave an answer

Quote of the day: live life