zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    命令行参数(argc, argv)
    [转]CodeSmith和PowerDesigner的使用安装和数据库创建
    INADDR_ANY的确切含义
    C++的CreateThread实例
    浅谈VC++中预编译的头文件放那里的问题分析
    [转]Windows网络编程学习-面向连接的编程方式
    char 转wchar_t 及wchar_t转char
    connect函数详解
    正斜杠(/)与反斜杠()区别
    C/C++关于string.h头文件和string类
  • 原文地址:https://www.cnblogs.com/swarb/p/9924237.html
Copyright © 2011-2022 走看看