I have a file I need to write to a temp location, what is the best place in Windows? This file needs to not move as I need to read it a couple of times and dispose it when I close the program.
Temp files often have the extension . TMP and are stored in the C:\Users\AppData\Local\Temp folder. If you're working on a document, your word-processing app may create a temporary file to track your progress. If the app crashes, you'll be able to recover your data from the temp file.
C:\WINDOWS\TEMP This directory stores temporary files generated by Windows itself. Most of what's stored here can be deleted as long as it's not locked for use. These two related directories are the other most crucial temporary data folders in the system.
C:\Users\<Username>\AppData\Local\Temp (This folder contain temporary information while a process is creating other files).
The Temp folder is a directory on your Windows PC used to store temporary files. Clearing the Temp folder is a standard procedure for system administration to reduce the amount of storage space used.
use
Path.GetTempPath();
or
Path.GetTempFileName();
As commentator pointed out, GetTempFileName() is not threadsafe - but you can construct unique file names based on GUIDs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With