Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
.NET 允许我创建和访问会话之间持久的值。 是否可以使用环境变量,例如%WINDIR%,%APPDATA%和其他? 如果是这样,我将如何去做?
%WINDIR%
%APPDATA%
如果你在配置中有这个:
<appSettings> <add key="SomePath" value="%TEMP%"/> </appSettings>
然后从代码中你会做类似的事情:
string path = ConfigurationManager.AppSettings["SomePath"]; string fullPath = System.Environment.ExpandEnvironmentVariables(path);