• ClickOnce手动更新


                if (ApplicationDeployment.IsNetworkDeployed == true)
                {
                    ApplicationDeployment thisDeployment = ApplicationDeployment.CurrentDeployment;
                    // this.Text = "正在检测更新";
                    this.txt_version.Text = thisDeployment.CurrentVersion.ToString();
                    if (thisDeployment.CheckForUpdate() == true)
                    {
                        thisDeployment.UpdateAsync();
                        thisDeployment.UpdateCompleted += (s, e) =>
                        {
                            if (e.Error == null)
                            {
                                MessageBox.Show("更新完毕,将要重启程序!");
                                Application.Current.Shutdown();
                                System.Windows.Forms.Application.Restart();
                            }
                            else
                            {
                                MessageBox.Show(e.Error.ToString());
                            }
                        };
                        thisDeployment.UpdateProgressChanged += (s, e) =>
                        {
                            string progressText = String.Format("{0:D}K out of {1:D}K downloaded - {2:D}% complete", e.BytesCompleted / 1024, e.BytesTotal / 1024, e.ProgressPercentage);
                            downloadStatus.Text = progressText;
                        };
                    }
                    else
                    {
                        MessageBox.Show("并没有新的版本进行更新!");
                    }
                }
                else
                {
                    MessageBox.Show("这不是网络发布的程序");
                }

    参考文章:

    http://www.cnblogs.com/sucsy/archive/2011/09/23/2186218.html

    http://www.cnblogs.com/luyu/archive/2005/12/03/289938.html

    http://www.cnblogs.com/chenxizhang/archive/2009/05/22/1486736.html

  • 相关阅读:
    SICP 习题1.16-1.19体会
    设计模式C++实现——组合模式
    QT官方下载地址
    浅析三角形測试程序
    操作系统开发之——进入保护模式
    PowerDesigner 打印错误
    @RequestParam注解一般用法
    Eclipse配置Maven的一些问题
    在windows上部署使用redis出现的问题及解决方法
    Eclipse导入模板格式Xml配置文件
  • 原文地址:https://www.cnblogs.com/swarb/p/9924237.html
Copyright © 2020-2023  润新知