Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best-Practices : how should I store settings in C# (Format/Type)?

Now I'm curious what are possibilities to store/load settings in .net. For example I need to store user name/password for different db's and etc.., also I need to store some options and etc.

My though was to create [Seriazable] class and save it to file...

What can You suggest? what are possibilities in .net and etc.

like image 477
Lukas Šalkauskas Avatar asked Feb 11 '09 06:02

Lukas Šalkauskas


1 Answers

The .NET Framework provides some mechanisms for storing and loading application and/or user settings. See "MSDN: Using Settings in C#" for the basics.

To encrypt some sensible data within your configuration files you can also use some standard functions of the .NET Framework. For a short introduction take a look at "Encrypting Configuration Information Using Protected Configuration" and "Encrypting Passwords in a .NET app.config File".

like image 68
Alexander Avatar answered Oct 17 '22 08:10

Alexander