I've written a program that calls the System.IO.Path.GetTempPath()
function. All the documentation I've read (like this one) says that the function should return the first path found from this list:
I have defined both the TMP
and TEMP
environment variables to be %USERPROFILE%\AppData\Local\Temp
, but the call to GetTempPath()
always returns my %USERPROFILE%
directory instead of the values I've define for TMP
and TEMP
. How can I get the function to return the temporary directory I've defined?
That is an Environment setting. http://msdn.microsoft.com/en-us/library/77zkk0b6.aspx
var tmp = Environment.GetEnvironmentVariable("tmp");
UPDATE: I went to a command prompt and did
SET TMP=C:\Temp
Then I launched visual studio from my command prompt. Now my environment is updated and visual studio sees it. The code above (as well as yours) worked for me. It displayed the updated environment settings.
So I believe you would have to kill explorer or logoff in order to get the new environment to be seen permenantly.