asp.net(c#)程序版本升级更新的实现代码(3)


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Threading;
using System.Net;
using System.Xml;
using Update;
namespace UpdateTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            checkUpdate();
        }
        public void checkUpdate()
        {
SoftUpdate app = new SoftUpdate(Application.ExecutablePath, "BlogWriter");
            app.UpdateFinish += new UpdateState(app_UpdateFinish);
try
{
if (app.IsUpdate && MessageBox.Show("检查到新版本,是否更新?", "Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
Thread update = new Thread(new ThreadStart(app.Update));
update.Start();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
        }
        void app_UpdateFinish() {
                MessageBox.Show("更新完成,请重新启动程序!", "Update", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
    }
}


好了,整个程序到此结束。如觉得有哪里不正确或者有疑问的请给我留言。

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wjjfdf.html