0

I have a C# application which allows user to create multiple profiles. For each profile he can create user settings. So the user can set different values for a given user setting for different profiles.

Example:

Let us say the user has Created 2 profiles : ProfileA and ProfileB.

For ProfileA he can set a value for DB connection string.

For ProfileB he can set a different value for DB connection string.

The user should be able to restore the settings after he closes and opens the application again. I am wondering what is the best way to store these settings in the .settings file. Please note that the user will be able to create profiles at runtime.

Is it possible to have sections for .settings file for a C# application similar to .ini file

Anoop
  • 101
  • 1
  • 10
  • 5
    If it is for users then isn't it better to just store it as xml? You could have a serializable class with whatever properties you need for unlimited number of profiles. – FCin Feb 28 '18 at 14:24
  • Agreed with @FCin's possible solution. Something like an app.config doesn't quite seem appropriate for what you're after. Especially considering you're managing these at runtime. – Broots Waymb Feb 28 '18 at 14:26
  • In Project Properties -> Settings, set the access level for your setting to `user` and the user's unique settings will be stored in their application folder – DiskJunky Feb 28 '18 at 14:26
  • 2
    @FCin Doesn't really matter if it's XML, JSON, ini file, database or even registry, OP hasn't shown any effort in trying to come up with a solution so this question is far too broad. – DavidG Feb 28 '18 at 14:27
  • @FCin you are right..but in the end they are just user settings(though for different profiles), so I am just tying to take advantage of inbuilt option provided by .net – Anoop Feb 28 '18 at 14:29
  • @DavidG I am currently using .ini with sections and it works for me..but I have seen posts mentioning .ini is not the recommended option anymore for user settings. So I just wanted to get suggestions for the best way to do this – Anoop Feb 28 '18 at 14:34
  • 1
    @Anoop Asking for "best practice" is also off topic here. If you have working code, then you may be better off posting on https://codereview.stackexchange.com (but read their rules before posting there - you obviously didn't read them before posting here) – DavidG Feb 28 '18 at 14:38

0 Answers0