Hey everyone,

Code:
        Using SW As New IO.StreamWriter(My.Application.Info.DirectoryPath & "\mods.cfg", True)
            For Each itm As FileInfo In Me.ListBox2.Items  <--- error points to this line
                SW.WriteLine(itm)
            Next
Using that code, i get the exception: Unable to cast object of type 'System.String' to type 'System.IO.FileInfo'.

The idea behind the code is swapping items between two text boxes, this bit is called to update a text file which stores the remaining items after an item is deleted from the list.
This code works fine if i start with a blank list, i can add and remove items from the list with no problems.
If i exit the program and reload with items stored in the second list, and i remove from the list i get that problem, but only if theres more than 1 item in the list. If its just the 1 item it works fine.

The code im using to add to the list is almost the same,

Code:
For Each itm As FileInfo In Me.ListBox2.Items
            If itm.Name = ListBox1.Text Then
                MsgBox("Already Active!", , "title")
                Exit Sub
            End If
        Next

        ListBox2.Items.Add(ListBox1.SelectedItem)

        Using SW As New IO.StreamWriter(My.Application.Info.DirectoryPath & "\mods.cfg", True)

            SW.WriteLine(ListBox1.Text)

        End Using
And i can add fine using the code, so i'm stumped as to where i've gone wrong.

Thanks for any help in advance!