I am trying to read Windows 2008 SP2 temp path using the code Path.GetTempPath();
and get unexpected result.
Instead of
C:\Users\Administrator\AppData\Local\Temp\
I get
C:\Users\Administrator\AppData\Local\Temp\2\
Why I get "2" at the end o开发者_如何学Cf path? There is no such temp path on my machine.
I've seen this when remotely connecting to a server that supports multiple sessions: each remote session, even for the same user, gets its own temp path.
I assume this is to prevent temporary files from two sessions by the same user possibly interfering.
I understand that setting "Use Temporary folders per session" in Terminal services configuration controls this behaviour.
Path.GetTempPath() looks for the Temp folder using
- The path specified by the TMP environment variable.
- The path specified by the TEMP environment variable.
- The path specified by the USERPROFILE environment variable.
- The Windows directory.
You might want to check the environment variables to see if any of those have a "2" at the end by mistake.
精彩评论