[VB.NET] Save listbox to a .txt with SaveFileDialog
SF1 = SaveFileDialog's name
lstaccounts = List you want to export
Put this code in the save button...
lstaccounts = List you want to export
sf1.InitialDirectory = "C:/"
sf1.FileName = "Accounts.txt"
sf1.Title = "Save Account List..."
sf1.Filter = ("text files (*.txt) | *.txt")
sf1.ShowDialog()
Dim w As New IO.StreamWriter(sf1.FileName)
Dim i As Integer
For i = 0 To lstaccounts.Items.Count - 1
w.WriteLine(lstaccounts.Items(i).ToString)
Next
w.Close()Put this code in the save button...