VB.net Media Player - Save playlist


I am trying to add the ability to save the playlist in my media player (based on WMP), so that it can be or will be loaded automatically in the next session.

The media player itself and the playlist work flawlessly. I've tried some methods I found on the web about this but I didn't have any luck with them.

More Specifically, I want the user to be able to save the playlist with a button and then load it with another button or automatically.

The Playlist is made with Listboxes. Both the file name and file path are being logged when the user opens a file.


As you asked, I am giving below the code that I am having problems with:

For the Save button

    Dim SaveFile As New SaveFileDialog
    SaveFile.Filter = "test playlist file |*.testfile"
    Dim WriteFile As New System.IO.StreamWriter(SaveFile.FileName)
    For i As Integer = 0 To ListBox1.Items.Count - Val(1)
        WriteFile.Write(ListBox1.Items.Item(i) & ";")
    For k As Integer = 0 To ListBox2.Items.Count - Val(1)
        WriteFile.Write(ListBox2.Items.Item(k) & ";")

For the Load button

    Dim OpenFile As New OpenFileDialog
    OpenFile.Filter = "test playlist file |*.testfile"
    Dim ReadFile As New System.IO.StreamReader(OpenFile.FileName)
    Dim Content As String = Readfile.ReadToEnd
    Dim SplittedContent() As String
    Dim Count As String
    SplittedContent = Content.Split(";")
    Count = SplittedContent.Count - Val(1)
    For i As Integer = 0 To Count
    For k As Integer = 0 To Count

Please note that Listbox1 holds the path of the file and Listbox2 the name of it respectively.

With this code, the file is saved successfuly, however it is empty when I open it with Notepad++.

Thank you

Show source
| save   | vb.net   | media-player   | playlist   2017-01-04 22:01 0 Answers

Answers to VB.net Media Player - Save playlist ( 0 )

Leave a reply to - VB.net Media Player - Save playlist

◀ Go back