Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Path.GetTempPath Method ()

 

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
SecurityException

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();
Console.WriteLine(result);

This example produces output similar to the following.

C:\Users\UserName\AppData\Local\Temp\

EnvironmentPermission

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

Universal Windows Platform
Available since 10
.NET Framework
Available since 1.1
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top
Show:
© 2016 Microsoft