Click here to Skip to main content
15,947,398 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
My Music File is in bin/debug Folders .
i have execute music file . but cannot execute.
i need a example Code :
string Path = "MusicFile" + Environment.CurrentDirectory;,)
/// NOW this Path execute for Paly music ?????!!!!!!!

ex for languages U.K . i cannot speak languages U.K Correctly.
Please Help me .thnx
Herman<T>.Instance 17-Sep-11 14:50pm    
do you know the exact path to the mp3 file?
Philippe Mori 17-Sep-11 18:56pm    
If you would use the debugger, you would see what wrong with your path.

It is fairly easy to see that it won't work as it will result in something like "MusicFilec:\CurrentDirectory". Notice that "MusicFile" is at the beginning. Also current directory might not be what you expect it to be (depending if it was set or not).

Don't put data file in executable folder. It is a bad pratice.

A file like a MP3 should be under user folder (and preferably in "My music".

By the way, your Path is wrong for sure...

1) "MusicFile" would never be at the beginning (before the current directory)
2) You should normally not use CurrentDirectory as it might be anything depending on how the application was started (from debugger, stanalone, from a shortcut...)
3) As mentionned above, you should use a folder specific to the current user.
4) You should use GetFolderPath[^] to get the desired parent folder.
5) You should then use Path.Combine[^] to build the complete filename.
Share this answer
Thanks Mr Mori ..........................................
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900