Click here to Skip to main content
15,616,232 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i got my listbox (listBox1)
i want to save the items inside and load them when form1 is loaded

i've got no idea so please explain everything you can

What I have tried:

i treid looking for this in the internet , i found nothing
some posts saying that making a .txt file is better but i don't like it
Updated 28-Jun-20 22:52pm

Top be honest, they "use a file" faction is probably right - settings files aren't really there for data and they aren't really good at it.

Using a file isn't difficult, and particularly with something like a list box it is the logical way to do it. It's even pretty easy, File.ReadAllLines will return each string separately in an array for you ready to load into your listbox, and File.WriteAllLines will save them back for you ready for next time if they get changed.

This will show you a good place to store the file: Where should I store my data[^]
Share this answer
Every .net application has got a configuration file: app.config already. If you don't see it, you can add it! See: How to add an app.config file to a project - Visual Studio | Microsoft Docs[^]

Please, read this article on CP KnowledgeBase: Read/Write App.Config File with .NET 2.0[^]

You can also use custom file:
- text file (*.txt, *.csv),
- xml file (*.xml),
- database file (*.mdb, *.db)
All you need to do is to provide methods to read/write proper data.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900