سؤال

When does Windows.Storage.ApplicationData.Current.TemporaryFolder get automatically cleared? If at all.

And if it doesn't get automatically cleared, then how does it differ to LocalFolder?

هل كانت مفيدة؟

المحلول

On Windows it can be cleared if the user runs Disk Cleanup. I believe temp folders can be cleared if the system is running low of storage space, which matters on low-memory Windows Phone devices, for instance.

Semantically, the point is that anything you put in temp cannot be relied upon at a later time, so you use it for caching and other stuff that can be restored if you find something missing. On the other hand, you can rely on the Local contents being there until you delete them and wouldn't need the same logic in your app.

On Windows Phone 8.1, temp files are also excluded from backup and restore operations, whereas Local is included. There's a LocalCache folder that is excluded from backup/restore as well, but isn't subject to arbitrary deletion.

It's true that if temp never got automatically cleared, it wouldn't be much different from Local/LocalCache. Even so, having a distinct folder like this lets you manage your app data more specifically, and you can always use Windows.Storage.ApplicationData.ClearAsync with an ApplicationDataLocality value to selectively clear out the temp folder yourself.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top