Samuel LIOULT
Samuel LIOULT

Reputation: 624

UWP Temporary folder cleaning

I would like to know if the temporary folder of the application is emptied automatically. If so, when is this done?

Upvotes: 5

Views: 2031

Answers (1)

Jay Zuo
Jay Zuo

Reputation: 15758

The Temporary folder can be cleaned up automatically whenever the device reaches a low-storage threshold.

The temporary app data store works like a cache. Its files do not roam and could be removed at any time. The System Maintenance task can automatically delete data stored at this location at any time. The user can also clear files from the temporary data store using Disk Cleanup. Temporary app data can be used for storing temporary information during an app session. There is no guarantee that this data will persist beyond the end of the app session as the system might reclaim the used space if needed.

The key point here is that anything you put in Temporary folder cannot be relied upon at a later time/after the current app session. For more info, please see Temporary app data.

And here are some best practices for Temporary folder:

  1. Use Temporary for any intermediate or temporary files. If you won’t need a file after your app is terminated or suspended, this is the right location for it.
  2. Clean your Temp folder during app initialization. If you are writing large amounts of data to Temp, it is a good idea to clear it when your app is initialized to avoid the system or the user having to take action to free up storage.

Upvotes: 4

Related Questions