App.config中设置环境变量部分路径 [英] App.config settings, environment variable as partial path

查看:164
本文介绍了App.config中设置环境变量部分路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来使用的app.config和xml修修补补,和我目前正在做的一些代码重构一些我没有写结果
目前,我们有一个片段看起来是这样的:

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>



我想要做的是有它,而不是指向类似 $ {} PROGRAMDATA ... \Company\

我怎样才能做到这一点,牢记PROGRAMDATA并不总是指向 C:?\ProgramData

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

推荐答案

我真的不希望改变它在代码中按对方的反应,因为这去除了它作为配置设置的目的。

I didn't really want to change it in code as per the other responses, since that removes the purpose of having it as a config setting.

事实证明, %ProgramData%\Company ... 就是在这种背景下使用环境变量的正确方法。

As it turns out, %ProgramData%\Company... is the proper way of using environment variables in this context.

这篇关于App.config中设置环境变量部分路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆