Come salvare una lista in formato testo ,Txt. How to save a list in text format, Txt.

 

If ListBoxLista.Items.Count = 0 Then Exit Sub

Dim lines As String()
Dim cont As Integer
Dim f As Integer

cont = ListBoxLista.Items.Count()

For f = 0 To cont - 1
ReDim Preserve lines(f)
lines(f) = ListBoxLista.Items(f)
Next

SaveFileDialog1.AddExtension = True
SaveFileDialog1.Filter = "Testo txt |.txt"
SaveFileDialog1.FileName = "Documento.txt"

If SaveFileDialog1.ShowDialog = vbCancel Then Exit Sub

Dim docPath As String = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)

Using outputFile As StreamWriter = New StreamWriter(Path.Combine(docPath, SaveFileDialog1.FileName))

For Each line As String In lines
outputFile.WriteLine(line)
Next
End Using

salvato = True