Get Temp Path Method
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Returns the path of the current user's temporary folder.
public: static System::String ^ GetTempPath();
public static string GetTempPath ();
static member GetTempPath : unit -> string
Public Shared Function GetTempPath () As String
The path to the temporary folder, ending with a DirectorySeparatorChar.
The caller does not have the required permissions.
The following code shows how to call the GetTempPath method.
Dim result As String = Path.GetTempPath() Console.WriteLine(result)
string result = Path.GetTempPath(); Console.WriteLine(result);
This example produces output similar to the following.
The method does not verify that the path exists or test to see if the current process can access the path.
This method checks for the existence of environment variables in the following order and returns the first path found:
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.
In .NET 7 and later, when the process calling the method is running as
SYSTEM, the method skips the preceding sequence and returns
C:\Windows\SystemTemp. This location is inaccessible to processes not running as