App.config settings, environment variable as partial path

Posted by Jean-Bernard Pellerin on Stack Overflow See other posts from Stack Overflow or by Jean-Bernard Pellerin
Published on 2011-03-14T18:59:42Z Indexed on 2011/03/16 0:10 UTC
Read the original article Hit count: 216

I'm new to tinkering with app.config and xml, and am currently doing some refactoring in some code I haven't written.
Currently we have a snippet which looks like this:

<setting name="FirstSetting" serializeAs="String">
  <value>Data Source=C:\Documents and Settings\All Users\ApplicationData\Company ...;Persist Security Info=False</value>

What I'd like to do is have it instead point to something like ${PROGRAMDATA}\Company\...

How can I achieve this, keeping in mind that PROGRAMDATA will not always point to C:\ProgramData ?

© Stack Overflow or respective owner

Related posts about c#

Related posts about Xml