Path.GetTempPath Method


Returns the path of the current user's temporary folder.

 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()
string result = Path.GetTempPath();

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:

  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.

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 SYSTEM.

Applies to

See also