I'm learning about how to use config files and I ran into some problems that I'm hoping someone here can give me some advice. It doesn't matter if my files are XML or not but the majority of examples I have read are using them and Im all for anything that makes my life easier.
the problem Im running into is that the appSettings file seems to be setup to only accept one value for one key and I would like to have something similar to:
<key="Machine List" value="Server105" />
<key="Machine List" value="Server230" />
Ive found a hack here but it was written over 6 years ago and I didn't know if there was a better way.
Again, it doesnt matter if this is XML, a flat file, etc.... Im just trying to learn how to use config files instead of hard coding values directly into the app.
Thanks for your help.
if you really need to store multiple machines under the key, it would be more appropriate to do:
<key="Machine List" value="Server105,Server230" />
with the delimiter being a character of your choosing.
An alternative to entry attributes would be to add child nodes to your setting node:
<setting key="Machine List">
<value>Server105</value>
<value>Server230</value>
</setting>
This way you don't need string manipulations to extract the different values.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With