Reputation:
.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?
Upvotes: 1
Views: 3650
Reputation: 15158
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);
Upvotes: 3