I'm trying to write a little Jukebox application in VB Forms, and I need the pathnames of the sound files (\bin\Tracks\"Insert Name Here") to be r开发者_运维百科elative instead of absolute, so that it may work on a different computer to mine. At the moment, I am testing with the simple Soundplayer class, and the single line of code to play a song is this:
My.Computer.Audio.Play("\bin\Tracks\" & txtCurrentlyPlaying.Text)
It works when, instead of \bin\Tracks\, I put the full pathname (C:\Documents And Settings etc.), but not when I try a relative path such as this. Can anybody help? Thank you for your time. Nick
Try Path.Combine(Environment.CurrentDirectory, txtCurrentlyPlaying.Text)
精彩评论