I have an application with some textboxes. My user fills the textboxes and runs some methods, when they close the application data is lost (normally).
I want to ke
There are a couple of options, but with most of them, you're going to be putting a file somewhere, whether it's a text file, resources/config or binary.
Using settings is one option: http://www.codeproject.com/Articles/17659/How-To-Use-the-Settings-Class-in-C
You can also take the serialization route: http://msdn.microsoft.com/en-us/library/vstudio/et91as27.aspx
Or you could possibly look into noSQL databases like MongoDB: http://www.mongodb.org/
Simplest way is binding your textboxes to application settings:
FormClosed
event save application settingsSaving settings:
private void Form_FormClosed(object sender, FormClosedEventArgs e)
{
Settings.Default.Save();
}
Next time when user will start your application, settings will be loaded from user-specific file, and textboxes will be filled with same data as it was before user closed an application last time.
Also in application settings you can store local variables, but you will have to add settings for them manually, and manually read that setting on application start:
var x = Settings.Default.MyCounter
Settings.Default.MyCounter = x
just before calling Settings.Default.Save()
You may use following
1- A local MS-ACCESS based db which can store small footprint.
2- Use Dictionary , Serilize/Deserilize it on hard disk (Uses FileSystem)
3- Store it in windows registry
Assuming you're on Windows (as the tags imply), have you considered the registry?