Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to save variable values on program exit?

I am trying to use an ArrayList to store a variable number of strings, and would like to know how to save the ArrayList and its elements so that my windows form can recall their value between program load and exit.

I used to store the information in a text file, but would like to avoid external files if possible.

Thank you for any help you could provide.

like image 730
user112016322 Avatar asked Jul 30 '12 12:07

user112016322


3 Answers

You can save the ArrayList (if not ArrayList their are other equivalent classes) using Properties.Settings best part is it allows you the setting variable at Application and user level

A very good example can be found here how to use Settigns http://www.codeproject.com/Articles/17659/How-To-Use-the-Settings-Class-in-C

like image 150
HatSoft Avatar answered Oct 24 '22 06:10

HatSoft


I've always done using (In Winforms in your case from the sounds of it), the Form_Closing to store to a Properties.Settings variable you'd create beforehand. If it's an ArrayList, you could store it to XML or a comma separated list. Your serizliation/deserialization method will depend on your data.

like image 2
Echilon Avatar answered Oct 24 '22 08:10

Echilon


Have a look at isolated storage.

like image 1
Yoeri Avatar answered Oct 24 '22 06:10

Yoeri