Click to See Complete Forum and Search --> : How to get "Temp" folder path?


Sin Jeong-hun
October 6th, 2002, 10:13 PM
How can I get "Temp" folder path with C#.

I've looked up System.Environment.SpecialFolder,
but "Temp" wasn't there.

In win 9X the temp path is typically
"C:\Windows\Temp"
In windows 2000,XP
"C:\\Windows\User Name\Local Settings\Temp


My current dirty solution is,

string tempinternet=System.Environment.GetFolderPath(
System.Environment.SpecialFolder.InternetCache);
string temppath=tempinternet.Substring(0,tempinternet.LastIndexOf("\\"))
+"\\temp";

But is this safe?

Tower
October 6th, 2002, 10:34 PM
From VS.Net Help

The following example code demonstrates the use of the GetTempPath method.

string tempPath = Path.GetTempPath();
Console.WriteLine("Temporary path is '{0}'", tempPath);