I would like to know how to take selected information from a listview and add them to a .dat file
This is what i got so far but it is to save into a text file
Sorry for any mistakes i am a noob
Private _filepath2 As String = Application.StartupPath & "\Teachers/Courses.dat"
Private Sub SaveToFile(LV As ListView, fpath As String)
Dim swriter As New StreamWriter(fpath, True)
Dim line As String
With swriter
For i As Integer = 0 To Listview1.Items.Count - 1
swriter.Write(Listview1.Items(i).Text)
For subItemIndex As Integer = 1 To Listview1.Items(i).SubItems.Count - 1
swriter.Write(Listview1.Items(i).SubItems(subItemIndex))
Next
sw.Write(line.NewLine)
Next
sw.Close()
End With
End Sub
and to call the function
Private Sub ButtonUpdate_Click(sender As Object, e As EventArgs) Handles ButtonUpdate.Click
SaveToFile(ListViewInformation, "Teachers/Courses.dat")
End Sub