Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should I store per-user data in WinForms?

Tags:

winforms

In my WinForms app, I have a few textboxes that the user typed some data into. I want to store the data, but I don't want to use a database. In my stone-age C++ days, I'd just use a .ini. Somehow, app.config doesn't seem like the right place to store this data, though.

What are my other options?

like image 679
JMP Avatar asked Sep 16 '09 19:09

JMP


People also ask

Are WinForms outdated?

Win Form has been used to develop many applications. Because of its high age (born in 2003), WinForm was officially declared dead by Microsoft in 2014.


2 Answers

I would say the .config file is the right place. Just be sure to use the User scoped area of the Settings.settings file rather than the Application scope.

This works well for simple data types and when you have fixed values that will need to be saved because you need to define what variables you want to store at design time. So if your textboxes are dynamically created and you don't know many values you need to store it is not very useful.

Using IsolatedStorage might be another good option. You can create your own file in any format you want (keeping any values you need) and store it to the local machine in "IsolatedStorage".

like image 124
auujay Avatar answered Oct 19 '22 15:10

auujay


You can create a folder somewhere on the disk and simply write a file in any suitable format (XML, plain text, your choice). You could for instance do this under the path pointed out by Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) or Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData).

like image 7
Fredrik Mörk Avatar answered Oct 19 '22 14:10

Fredrik Mörk