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

时间:2021-05-28

直接上代码:
复制代码 代码如下:
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.IO;
using System.Net;
using System.Xml;
namespace Update
{
/// <summary>
/// 更新完成触发的事件
/// </summary>
public delegate void UpdateState();
/// <summary>
/// 程序更新
/// </summary>
public class SoftUpdate
{
private string download;
private const string updateUrl = "https://ponent();
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);
}
}
}

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

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章