|
-
Oct 19th, 2009, 09:05 PM
#7
Thread Starter
Hyperactive Member
Re: Saving Items in listbox
 Originally Posted by jmcilhinney
Assuming that the ListBox contains just Strings:
vb.net Code:
Dim items(Me.ListBox1.Items.Count - 1) As String Me.ListBox1.Items.CopyTo(items, 0) IO.File.WriteAllLines("file path here", items)
or with LINQ:
vb.net Code:
IO.File.WriteAllLines("file path here", _ Me.ListBox1.Items.Cast(Of String)().ToArray())
To reload:
vb.net Code:
Me.ListBox1.Items.AddRange(IO.File.ReadAllLines("file path here"))
I would like to store some other things in the Text File, how do I get it to only read part of the file?
Reloading it doesnt work. I put the code in my Formloading, and nothing happened. I checked the Text File and there was text
Last edited by werido; Oct 19th, 2009 at 09:11 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|