using music file in soundPlayer function

  • Thread starter Thread starter ss
  • Start date Start date
S

ss

hi!
i would like to use a file that is located in my project folder.
i don't want to use the full path like c:\project\game\whoss.wav (where
game is the folder for .sln file)
hos can i write a reference to the place where the solution is?
 
Application.Path
.... contains a reference to the execution folder.
Relative paths normally work as well.
 
the probelm is that the execution folder is 'bin' and i can't save
there the music - it's not a good path to load from
any other idea?
 
Hell,

Well you could create a sub folder inside the folder where your exe is
running from and call the file as follows

string MusicFileName = "test.mp3";
Application.StartupPath + "music\" + MusicFileName;

Hope this helps.

Regards
Scott Blood
C# Developer
 
I may be confused as to your actual requirements.

Do you want your installed application to reference a path in a
completely different location?
Could you use a FolderBrowserDialog to let the user choose their
project path?
Otherwise do as Scott says; create a sub folder that is relative to
your executable.
Eg. string path = Application.StartupPath + @"..\..\";
This would be 2 directories above where your EXE is running from.

SN
 
Back
Top