Skip to content

Commit e58c2ef

Browse files
authored
Update Path.GetTempPath description (#10118)
1 parent 8bd248a commit e58c2ef

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

xml/System.IO/Path.xml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2298,25 +2298,17 @@ On .NET 7 and earlier versions, when using this method on Windows, the <xref:Sys
22982298
22992299
The method does not verify that the path exists or test to see if the current process can access the path.
23002300
2301-
This method checks for the existence of environment variables in the following order and returns the first path found:
2302-
23032301
# [Windows](#tab/windows)
23042302
2305-
1. The path specified by the TMP environment variable.
2306-
2307-
2. The path specified by the TEMP environment variable.
2308-
2309-
3. The path specified by the USERPROFILE environment variable.
2310-
2311-
4. The Windows directory.
2303+
If the current Windows version exposes the [`GetTempPath2`](https://learn.microsoft.com/windows/win32/api/fileapi/nf-fileapi-gettemppath2w) Win32 API, this method invokes that API and returns the resolved path. For more information on how this resolution is performed, including how to control the return value through the use of environment variables, see [the _Remarks_ section](https://learn.microsoft.com/windows/win32/api/fileapi/nf-fileapi-gettemppath2w#remarks) of the GetTempPath2 documentation. The GetTempPath2 API might not be available on all versions of Windows.
23122304
2313-
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`.
2305+
On Windows versions that don't expose GetTempPath2, this method instead invokes the [`GetTempPath`](https://learn.microsoft.com/windows/win32/api/fileapi/nf-fileapi-gettemppathw) Win32 API and returns the resolved path. For more information on how this resolution is performed, including how to control the return value through the use of environment variables, see [the _Remarks_ section](https://learn.microsoft.com/windows/win32/api/fileapi/nf-fileapi-gettemppathw#remarks) of the GetTempPath documentation.
23142306
23152307
# [Linux](#tab/linux)
23162308
2317-
1. The path specified by the TMPDIR environment variable.
2309+
If the `TMPDIR` environment variable has been set, this method returns the value specified by that environment variable.
23182310
2319-
2. The path `/tmp/`.
2311+
Otherwise, this method returns `/tmp/`.
23202312
23212313
---
23222314

0 commit comments

Comments
 (0)