hello guys can you help me with my problem
i create a media player and of course it has a playlist which is the listbox but my problem is that when i use this

x = system.io.path.getfilename(track)

and when i click the song in the playlist it does not play the song...

for the song is from C:\blah\this is war.mp3

with this code playlist.selecteditem.add(track) it will output in the playlist(listbox) is the C:\blah\this is war.mp3 and when i click that of course it will play the song

but.....

when i use this

x = system.io.path.getfilename(track)  
 playlist.selecteditem.add(x)

it will output in the playlist(listbox)
this is war.mp3 <-- it remove the c:\blah\
but the problem is that it does not play the song..

Can someone help me with problem?

Recommended Answers

All 3 Replies

x = system.io.path.getfilename(track) will only give you the filename.

If you want to display only the filename, but still have access to the full path, then I suggest that you add a second, hidden, ListBox where you store the full path and filename.
And every time that you add another track to the playlist, then at the same time add the full path to the second ListBox using the "track" string.

So, when you click the song in the playlist, the song gets played from the second ListBox.

You could also use a ArrayList to store the FullPath of a file.
.Check out this thread for some basic info on using a ArrayList.

thanks guys but I already solve the problem using two listbox the first listbox use the system.io.path.getfilename and the other one not use and in the selected listbox which use the system.io.path.getfilename when the item is selected it will also select the lsitbox2------> [code] listbox1.selecteditem = listbox2.selecteditem [\code] same idea with you oxiegen:) and also codeorder thank to the link another algorithm:)

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.