0

I am trying to display my track's title instead of its path in my listbox, and it works! But when I go to play it on my media player later, I cannot because it does not have the file path. Is there a way I could somehow save the file's metadata and path to my listbox, preferably with the path hidden? If so, how?

TagLib.File tagFile = TagLib.File.Create(file.FullName); // track is the name of the mp3
MusicBox.Items.Add(tagFile.Tag.Title);

I am using a windows media player control and the TagLib library.

Klink45
  • 439
  • 1
  • 6
  • 21
  • Take a look at listbox's `displaymember` and `valuemember`. In your case it would look like `MusicBox.DisplayMember = "Tag.Title"; MusicBox.ValueMember = "Tag.FilePath";` where MusicBox is a listbox of `TagLib` type. I may have gotten the specifics wrong, but I believe this can help you: [C#: How to bind to ListBox DisplayMember and ValueMember result from class method?](http://stackoverflow.com/questions/25103408/c-how-to-bind-to-listbox-displaymember-and-valuemember-result-from-class-metho) – Keyur PATEL Aug 31 '16 at 01:41
  • Will that work with multiple items in the listbox? – Klink45 Aug 31 '16 at 02:37
  • It should, I think it works if all the items inside are of the same type. It defines what each item displays. – Keyur PATEL Aug 31 '16 at 09:18
  • I attempted that. Did not work :( – Klink45 Aug 31 '16 at 19:19

0 Answers0