Metro(XAML/C#):检测安装和/或首次运行 [英] Metro (XAML/C#): detect installation and/or first run
问题描述
在XAML/C#中创建Metro应用程序时,如何检测自安装(或潜在升级)以来首次安装或首次运行该应用程序的时间?我需要利用这个机会来确保我的数据库架构正确,并可能同步一些基本数据.
When creating Metro applications in XAML/C#, how do I detect when the application is first installed or run for the first time since installation (or potentially upgrade)? I need to use this opportunity to ensure that my database schema is correct and potentially synchronise some base data.
我曾希望可以从OnLaunched
方法中的LaunchActivatedEventArgs
中选择它,但是似乎没有可以使用的Kind
或PreviousExecutionState
的有效值.
I had hoped that I could pick this up from the LaunchActivatedEventArgs
within the OnLaunched
method, but there does not seem to be a valid value for the Kind
or PreviousExecutionState
that I can use.
谢谢.
推荐答案
When your app starts, write a setting called "AppHasBeenStarted" or something to LocalSettings. If the setting has not already been written, you know your app hasn't been started before. And you could improve on this, by making it "AppVersion", and writing the app's version. This way your app can detect upgrades by comparing the stored version with its own version.
这篇关于Metro(XAML/C#):检测安装和/或首次运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!