更新我的Windows Store应用 [英] Updating my Windows Store App

查看:97
本文介绍了更新我的Windows Store应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更新Windows Store应用程序,但是我需要删除应用程序本地状态文件夹中的所有内容:

I would like to update my Windows Store App, but I need to delete everything in the local state folder of the application:

C:\Users\usr1\AppData\Local\Packages\myApp\LocalState

我对更新Windows Store App和官方文档并未阐明如何清除文件夹,就像重新安装该应用程序一样。

I am not familiar with the process of updating Windows Store App and the official documentation does not clarify how can I clear the folder just as if the App was reinstalled.

我想知道我是否必须手动执行此操作(使用应用程序的版本号)还是是否有自动化的方式来执行它。

I was wondering if I had to do this by hand (using the version number of the App) or if there was an automated way to perform it.

推荐答案

首先让我提供一些背景知识。根据设计,在安装应用程序更新时会保留应用程序数据。原因是状态(应用程序数据)的版本通常与应用程序本身的版本无关。也就是说,一个应用程序可以在1.3和4.1版本之间使用,并且仍使用相同的应用程序数据结构。

Let me first give a little background. By design, app data is preserved across the installation of app updates. The reason for this is that the versions of your state (app data) are typically a separate concern from the versions of the app itself. That is, an app could go between versions 1.3 and 4.1 and still use the same app data structures.

应用程序数据的版本是通过Windows.Storage.ApplicationData设置的。 .SetVersionAsync( http:// msdn。 microsoft.com/en-us/library/windows/apps/windows.storage.applicationdata.setversionasync.aspx )。这主要与漫游数据有关,因为此版本标记确定了在云中保留了哪些不同的漫游数据副本。

The version of the app data is set through Windows.Storage.ApplicationData.SetVersionAsync (http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.applicationdata.setversionasync.aspx). Where this primarily matters is with roaming data, as this version mark determines what distinct copies of the roaming data are preserved in the cloud.

现在,您在说的是有关本地应用程序数据而不是漫游的信息,在这种情况下,您可以使用SetVersionAsync,也可以自己维护应用程序数据中的版本号。对于您的情况(听起来像清除各种缓存),使用自己的设置可能更好,因为如果/当您使用漫游状态时,您不必每次更新应用程序时都更改应用程序数据版本。

Now in your case you're talking about local app data, not roaming, in which case you can either use SetVersionAsync, or you can simply maintain a version number in an app data setting yourself. For your scenario (which sound like clearing out a cache of sorts), using your own setting is probably better, because if/when you use roaming state you won't be having to change the app data version with every app update.

如果您拥有自己的版本号,则只需编写更新的应用程序即可检查您不想保留的任何版本。如果存在该版本,请调用ApplicationData.ClearAsync(ApplicationDataLocality.Local)(请参阅 http://msdn.microsoft.com/en-us/library/windows/apps/hh701425.aspx )。您可以不带参数地调用ClearAsync来一起清除本地,临时和漫游。

If you have a version number of your own, then, simply write your updated app to check for whatever version you don't want to carry forward. If that version exists, then call ApplicationData.ClearAsync(ApplicationDataLocality.Local) (see http://msdn.microsoft.com/en-us/library/windows/apps/hh701425.aspx). You can call ClearAsync with no args to clear local, temp, and roaming all together.

如果由于某种原因您具有可以迁移而不是重建的状态,那么您可以使用该版本号来检查您需要迁移的内容。

If for any reason you have state that can be migrated instead of rebuilt, then you can use that version number to check for what you need to migrate.

另一种方法是将后台任务与ServicingComplete触发器一起使用。此处的指南是: http://msdn.microsoft。 com / en-us / library / windows / apps / jj651556.aspx 。基本上,您只需像以前一样执行后台任务调用ClearAsync和/或迁移状态。

The other way to do this is to use a background task with the ServicingComplete trigger. A guide for that is here: http://msdn.microsoft.com/en-us/library/windows/apps/jj651556.aspx. You'd basically just have the background task call ClearAsync as before and/or migrate the state.

这篇关于更新我的Windows Store应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆