Path.GetTempPath Method ()


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

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

Namespace:   System.IO
Assembly:  mscorlib (in mscorlib.dll)

public static string GetTempPath()

Return Value

Type: System.String

The path to the temporary folder, ending with a backslash.

Exception Condition

The caller does not have the required permissions.

This method checks for the existence of environment variables in the following order and uses 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.

The following code shows how to call the GetTempPath method.

string result = Path.GetTempPath();

This example produces output similar to the following.



for unrestricted access to environment variables. Associated enumeration: PermissionState.Unrestricted

Universal Windows Platform
Available since 10
.NET Framework
Available since 1.1
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top