Search code examples
c#.netconnection-stringuser-preferences

Where should I store user config data? Specificaly the path to the data file?


I have an app using a SQLite db, and I need the ability for the user to move the data file and point the app to where it moved to. I used the Entity Framework to create the model, and by default it puts the connection string in the App.Config file. From what I've read if I make changes to the connection string there then they won't take effect until the app is restarted. That seems a bit clunky for my use. I see how I can init my model and pass in a custom string but I'm unsure what the best practice is in where to store basic user prefrences such as this? Ini, Registry, somewhere else? I don't want the user to have to "Open" the file each time, just when it relocates and then the app will try to auto open from then on.


Solution

  • Have a look at Application Settings for an overview of how to create user-specific config settings which can be saved to a user.config file. The registry is more or less abandoned in favour of the new xml-based config file system.