Link to home
Start Free TrialLog in
Avatar of derek7467
derek7467

asked on

Save combobox entries to textfile

I have a combobox that i want to save to a textfile when clicking a button, it should append all entries to a new line UNLESS it already exists. I have the below code, but it doesnt save, it doesnt do anything, but no errors.

   Dim content(TextBox1.Items.Count - 1) As String
        TextBox1.Items.CopyTo(content, 0)
        IO.File.WriteAllLines("C:\SWDEPOT\test.txt", content)

Open in new window


If a prepopulate the textfile with entries i am able to load it completely fine with the below code:

Dim load() As String = IO.File.ReadAllLines("C:\SWDEPOT\test.txt")
        Array.Reverse(load)
        TextBox1.Items.AddRange(load)

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial