volevo sapere se il codice evidenziato presenta degli errori, se si come faccio a salvare il contenuto di un ListView in un file txt
codice:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim fs As New FileStream("file.txt", FileMode.Create, FileAccess.Write)
'declaring a FileStream and creating a word document file named file with
'access mode of writing
Dim s As New StreamWriter(fs)
Dim i As Integer
'creating a new StreamWriter and passing the filestream object fs as argument
s.BaseStream.Seek(0, SeekOrigin.End)
'the seek method is used to move the cursor to next position to avoid text to be
'overwritten
For i = 1 To ListView1.Items.Count
s.Write(ListView1.Items(i).Text)
' s.WriteLine("This concept is interesting.")
'writing text to the newly created file
Next
s.Close()
'closing the file
End Sub