4

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

Also, how would I make it store it in Roaming instead of Local?

Leagsaidh Gordon
  • 1,641
  • 5
  • 19
  • 28

1 Answers1

1

Rather than getting rid of the "hash or something", I did this by adding a string property CurrentVersion to the settings. Then on 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();
    }
}

Don't know how you'd go about moving them to the roaming profile though. Sorry.

spender
  • 117,338
  • 33
  • 229
  • 351