Because i had to transfer my project to my lecturer but what the file location that works for my computer does not necessary work for my lecturer computer. Althought i transfer my wav file to the project workspace Alarm clock in the bin section. So how to allow my wav file to be able to be located for any computer?

myPlayer.SoundLocation = @"C:\Users\XXXXXXX\Desktop\XXXXXX\Alarm Clock\bin\A.wav";

You could replace the current file path, with a relative path OR you could also add the .wav file in your project's resources so that you dont have to spesify a different path everytime that you install your app.

Hope i helped :)

May i know how to add the wav file to my project's resources? And allow the above code to find it? Thanks in advances :)

Of course you can. :D

1)Right-click your project on the Solution Explorer
2)Click Properties
3)On your Middle Left there's a tab, called 'Resources'
4)By default it will open the String Resources. There you see a "String1" text. Above that it says Strings. Click that and select Audio
5)Then click Add Resource -> Add Existing File
6)Navigate to the path that the .wav is located, and select it.


Now you have successfuly added the wav file to your Project resources. :)

After that you need to access your wav resource through code. TO do that, all you have to do is to create a new Wav Object in your code which will be your wav from resource( Im not exactly sure how can you create a wav object, but you can search it)
like this:

Wav w = This.resources.<Name of the file that you added>


Hope i helped. :D

I'm still quite unsure about the last part of the post on

TO do that, all you have to do is to create a new Wav Object in your code which will be your wav from resource( Im not exactly sure how can you create a wav object, but you can search it)
like this:

Wav w = This.resources.<Name of the file that you added>

Mate,
You're very lucky! :p

I just found a complete guide (with pictures and code) that will solve your problem..

Click Me!

Hope this helps.
Alex

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.