Answers for "c# save listbox to text file"

VBA
0

add text file to listbox c#

OpenFileDialog f = new OpenFileDialog();
    if (f.ShowDialog() ==DialogResult.OK)
    {
        listBox1.Items.Clear();

        List<string> lines = new List<string>();
        using (StreamReader r = new StreamReader(f.OpenFile()))
        {
            string line;
            while ((line = r.ReadLine()) != null)
            {
                listBox1.Items.Add(line);

            }
        }
    }
Posted by: Guest on November-07-2020
0

write listbox to text file vb.net

Private Sub SaveButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveButton.Click
    If SaveFD.ShowDialog() = DialogResult.OK Then
        Dim sb As New System.Text.StringBuilder()

        For Each o As Object In ListBox1.Items
            sb.AppendLine(o)
        Next

        System.IO.File.WriteAllText("c:mypathoutput.txt", sb.ToString())
    End If
End Sub
Posted by: Guest on October-21-2020

Code answers related to "VBA"

Browse Popular Code Answers by Language