Windows temp file location [duplicate]

Tag: windows Author: berylgan7 Date: 2009-08-28

Possible Duplicate:
Correct location to save a temporary file in Windows?

Where is a safe place to create tmp file on windows?

What do you mean by "safe" please? There is already a well known and understood temp folder as the answers show
i mean on *nix systems i can create a file in /tmp without permission problems i was looking for an equalent location for windows.

Other Answer1

Use the GetTempPath API, or the equivalent in your programming environment (for .NET, that would be Path.GetTempPath).

Other Answer2

In Win32, you use GetTempFileName, and in .NET, you use System.Io.Path.GetTempFileName.

Not in one of those languages? Check Creating a Secure Temporary File on Rosetta Code.

Other Answer3

What about the Temp directory? You can find its location in the %TEMP% environment variable or programmatically using the GetTempPath() function.

Other Answer4

If you're not using a full-blown programming language, you should place temp files in the folder whose name is stored in the environment variable %TEMP% or %TMP%


Yes, based on the non-programming nature of the question (no references to a programming language), I would guess this is the answer. If so, this question really belongs on !

Other Answer5

You can use %TMP% as a valid path that actually points to the users temp folder in windows.

Example (copy thefile.txt to the temp folder and rename to tmpfile.txt):

copy thefile.txt %TMP%\tmpfile.txt

To see where the actual location of the temp folder is, just run

echo %TMP%