0

I started out using Properties.Settings.Default to keep settings for my application, but now the requirements have changed, and we need to keep those settings in an SQL database instead of a file on disk. I'll have to load the xml to a string, and then somehow initialize the settings from that string.

I'd rather not have to discard all code related to Properties.Settings.Default and use a different class. I need something like void Properties.Settings.Default.LoadSettingsXmlFromString(string xml), and string Properties.Settings.Default.SaveSettingsToString(). I would then handle storing and loading the string myself.

One easy solution that comes to mind is to retrieve the settings from the server, and then overwrite the file that Properties.Settings.Default will load, and likewise for saving.

I also found Loading Properties.Settings from a different file at runtime, but my problem is a little different, since I'm not loading the settings from a file on disk at all.

Edit: It seems even getting the file location so I can overwrite it will not be easy, according to how to change .NET user settings location

sashoalm
  • 75,001
  • 122
  • 434
  • 781
  • FWIW, refactoring tools a are pretty nice these days... I'm not sure you can override the Default settings, but if you were to match it to your own separate implementation, would it be that much of a hassle to use the refactoring tools to rename all your existing references? Seems like the way to go, especially considering long term cleanliness and maintainability. – jleach Oct 31 '16 at 10:54
  • @jdl134679 Yes, but then I have to write that separate implementation. And then refactor my code, and no matter how good refactoring tools are, this can always create regressions. I'd rather avoid having to refactor my code if possible. I'll at least wait a few hours to see if there is a solution to the question I asked here. – sashoalm Oct 31 '16 at 10:58

0 Answers0