I have a .NET 2.0 Windows Forms application. Where is the best place the store user settings (considering Windows guidelines)?
Some people pointed to Application.LocalUserAppDataPath
. However, that creates a folder structure like:
C:\Documents and Settings\user_name\Local Settings\Application Data\company_name\product_name\product_version\
If I release version 1 of my application and store an XML file there, then release version 2, that would change to a different folder, right? I'd prefer to have a single folder, per user, to store settings, regardless of the application version.
The settings are stored in user. config. Full path: %USERPROFILE%\Local Settings\Application Data\<Company Name>\ <appdomainname>_<eid>_<hash>\<verison>\user.
User settings are saved in a file within a subfolder of the user's local hidden application data folder.
User-scope settings are stored in the user's appdata folder. Application-scope settings are stored in C:\Users\My Name\AppData\Local\My_Company\. If your settings file doesn't contain any Application-scope settings, you won't have a company folder.
For your requirement, I suggest you export installation configuration files to save the workload and component information: open your VS installer > More > Export configuration. Meanwhile, you can export your environment settings by launching your VS > Tools > Import and Export settings.
I love using the built-in Application Settings. Then you have built in support for using the settings designer if you want at design-time, or at runtime to use:
// read setting string setting1 = (string)Settings.Default["MySetting1"]; // save setting Settings.Default["MySetting2"] = "My Setting Value"; // you can force a save with Properties.Settings.Default.Save();
It does store the settings in a similar folder structure as you describe (with the version in the path). However, with a simple call to:
Properties.Settings.Default.Upgrade();
The app will pull all previous versions settings in to save in.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With