Im looking to play a sound from a folder which is in my debug directory.

I got this working for a PictureBox:

PictureBox1.ImageLocation() = ("Resources\picture.png")

But I cant find something to play a sound. This is what I had before:

My.Computer.Audio.Play("C:\Users\......\Sounds\beep-2.wav")

I dont really want to be writing the location of the files using special directories. Is there any way I can just set the location of the file to the directory in which the .exe is.

Edited by BleepyE: n/a

3
Contributors
6
Replies
7
Views
5 Years
Discussion Span
Last Post by BleepyE

Try This :

Application.StartupPath

Nah I get this error when trying the following code
Conversion from string "Beep-2" to type 'Integer' is not valid.

My.Computer.Audio.Play(Application.StartupPath("Beep-2"))

Change with this :

My.Computer.Audio.Play(Application.StartupPath & "\beep-2.wav")

Edited by Jx_Man: n/a

Ahh ofcourse. The problem I have is that I tried just to use to full location of the sound file, but no sound played.

Now using this method the sound also doesnt play, but im listenning to music etc.

Ive also had a problem with resources, non of pictureboxes will occupy an image in my resources.

Im not sure if this is a linked problem. But im going to reboot my maching and try again.

Are your files are in debug folders when you build ur application?
in debug mode can u check?

Yes they were, and its working now. Just needed a reboot.
Thanks