Possible Duplicate:
Correct location to save a temporary file in Windows?
Where is a safe place to create tmp file on windows?
Possible Duplicate:
Correct location to save a temporary file in Windows?
Where is a safe place to create tmp file on windows?
Use the GetTempPath API, or the equivalent in your programming environment (for .NET, that would be Path.GetTempPath).
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.
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%
What about the Temp directory? You can find its location in the %TEMP%
environment variable or programmatically using the GetTempPath()
function.
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%