Where is the best place to save temporary files in Windows

Charles Faiga picture Charles Faiga · Aug 7, 2009 · Viewed 10.7k times · Source

I am busy writing an application that runs under windows

Where is the correct place to save temporary files ?

Answer

Steve Guidi picture Steve Guidi · Aug 7, 2009

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.