문제

.NET allows me to create and access values that are persistent between sessions.
Is it possible to use environment variables such as %WINDIR%, %APPDATA% and others?
If so, how would I go about doing this?

도움이 되었습니까?

해결책

If you have this in the config:

 <appSettings>
   <add key="SomePath" value="%TEMP%"/>
 </appSettings>

Then from code you'd do something like:

string path = ConfigurationManager.AppSettings["SomePath"];
string fullPath = System.Environment.ExpandEnvironmentVariables(path);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top