Exemplo n.º 1
0
        private async Task UpdateSelf()
        {
            try
            {
                var newVersion = await WebServiceClient.GetSelfVersion();

                var currentVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
                if (newVersion > currentVersion)
                {
                    MessageBox.Show($"检查到更新器最新版本 {newVersion},当前版本 {currentVersion},点击确定开始更新。");
                    await WebServiceClient.DownloadSelf();

                    System.IO.File.WriteAllBytes(Util.MakeQualifiedPath("amtLauncher.exe"), amt.Properties.Resources.amtLauncher);
                    Process.Start(Util.MakeQualifiedPath("amtLauncher"), "--ReplaceUpdater");
                    Shutdown();
                }
            }
            catch (HttpRequestException)
            {
                MessageBox.Show("因网络问题,更新无法完成,请稍候重试!");
                Shutdown();
            }
        }