开发者

Path.GetTempPath() unexpected symbol at the end of path

开发者 https://www.devze.com 2023-04-08 14:58 出处:网络
I am trying to read Windows 2008 SP2 temp path using the code Path.GetTempPath(); and get unexpected result.

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

  1. The path specified by the TMP environment variable.
  2. The path specified by the TEMP environment variable.
  3. The path specified by the USERPROFILE environment variable.
  4. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消