Reputation: 2777
I develop a Windows desktop console application in C#.
I like to save some user configurations in groups or sections. Here is an example:
[Email Peter]
UserName=Peter
POP=mail.server1.com
SMTP=smtp.server1.com
[Email Paul]
UserName=Paul
POP=mail.hotmail.com
SMTP=smtp.hotmail.com
I looked at Project, Properties, Settings and there are only names and values, no sections or groups.
And I looked at the ConfigurationManager Class, and there are also no sections or groups - at least I didn't see them.
I am sure many people have similar requirements but I can’t find a built in solution.
Sure, I can write these values in a text file like an ini file but I guess that is not the recommended way to do this.
Any suggestions?
Upvotes: 0
Views: 76
Reputation: 1281
It doesn't seem very good idea to store this kind of data in project's settings. I would add userSettings.xml file instead (if you cannot store this data in database). This would allow you to set your data in "groups" as you wish. For example:
<userSettings>
<user id="Peter">
<UserName>Peter</UserName>
<POP>mail.server1.com</POP>
<SMTP>smtp.server1.com</SMTP>
</user>
<user id="Paul">
<UserName>Paul</UserName>
<POP>mail.hotmail.com</POP>
<SMTP>smtp.hotmail.com</SMTP>
</user>
</userSettings>
Upvotes: 1