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.

Recommended Answers

All 6 Replies

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")

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.