Make C # user.config version independent

My C # project uses the default configuration file ( Properties > Settings.settings ), which stores the configuration file in %userprofile%\AppData\Local\MyApp\MyApp.exe_Url_hashorsomething . How can I do the same without this last directory or so that the last directory does not depend on the name of the exe and the hash (or whatever that part is).

Also, how can I save it in Roaming instead of Local?

+4
source share
1 answer

Instead of getting rid of the "hash or something", I did this by adding the string property CurrentVersion to the settings. Then at startup, I can call the following method:

 public static void UpgradeSettingsIfRequired() { string version = Assembly.GetEntryAssembly().GetName().Version.ToString(); if (Settings.Default.CurrentVersion != version) { Settings.Default.Upgrade(); Settings.Default.CurrentVersion = version; Settings.Default.Save(); } } 

I don’t know how you could move them to the roaming profile. Unfortunately.

+1
source

All Articles