Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is the best place to save temporary files in Windows

Tags:

I am busy writing an application that runs under windows

Where is the correct place to save temporary files ?

like image 232
Charles Faiga Avatar asked Aug 07 '09 20:08

Charles Faiga


People also ask

Where do I put temporary files?

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.

Which folder does Windows use to store temporary files?

The Temporary files created by the Windows operating system are usually stored in the %system%\Windows\Temp folder, whereas the ones created by the User when running any software is stored in his user profile at %userprofiles%\AppData\Local\.

Where are all temp files stored in Windows 10?

C:\Users\<Username>\AppData\Local\Temp (This folder contain temporary information while a process is creating other files).

Is it OK to delete temp files?

If you're running low on storage space, you should consider deleting the temp files. You can either delete some or all of the temp files. Deleting them will free up space that you can use for other files and data. Keep in mind that you may not be able to delete temp files while the respective program is still running.


1 Answers

If you are using .NET, please use Path.GetTempPath(). This will guarantee that you use the temporary directory assigned to the user that runs your application, regardless of where it is stored.

If you browse the file system, you will notice that there are many "temp" directories:

  • ~\Temp
  • ~\Windows\Temp
  • ~\Users\userName\AppData\Local\Temp

... and many more. Some of these paths are OS-dependent, and won't be present on certain windows flavors. So, save yourself some time and hassle, and let the .NET framework figure out where the "temp" path is located.

like image 170
Steve Guidi Avatar answered Sep 16 '22 11:09

Steve Guidi