C#使用 AutoUpdater.NET 实现程序自动更新

写在前面

开发桌面应用程序的时候,经常会因为新增功能需求或修复已知问题,要求客户更新应用程序,为了更好的服务客户,通常会在程序启动时判断版本变更情况,如发现新版本则自动弹出更新对话框,提醒客户更新成最新版本。在.Net体系中采用 AutoUpdater.NET 组件可以非常便捷的实现这一功能。

老规矩从NuGet获取 AutoUpdater.NET 组件:

参考官方示例

代码实现

新建WinForm示例程序,主要代码如下:

cs 复制代码
namespace AutoUpdaterWinFormsApp
{
    using AutoUpdaterDotNET;

    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            AutoUpdater.InstalledVersion = new Version("1.2");
            System.Timers.Timer timer = new System.Timers.Timer
            {
                Interval = 1 * 30 * 1000,
                SynchronizingObject = this
            };
            timer.Elapsed += delegate
            {
                AutoUpdater.Start("https://rbsoft.org/updates/AutoUpdaterTest.xml");
            };
            timer.Start();
        }
    }
}

xml配置:

XML 复制代码
<?xml version="1.0" encoding="UTF-8"?>
<item>
	<version>2.0.0.0</version>
	<url>https://rbsoft.org/downloads/AutoUpdaterTest.zip</url>
	<changelog>https://github.com/ravibpatel/AutoUpdater.NET/releases</changelog>
	<mandatory>false</mandatory>
</item>

调用示例

相关推荐
Dev7z1 天前
基于MATLAB HSI颜色空间的图像美颜系统设计与实现
开发语言·matlab
superman超哥1 天前
仓颉语言中字符串常用方法的深度剖析与工程实践
开发语言·后端·python·c#·仓颉
bugcome_com1 天前
C# 中 ref 与 out 参数传递:核心区别与实战解析
c#
想学后端的前端工程师1 天前
【Spring Boot微服务开发实战:从入门到企业级应用】
java·开发语言·python
刺客-Andy1 天前
js高频面试题 50道及答案
开发语言·javascript·ecmascript
夏幻灵1 天前
指针在 C++ 中最核心、最实用的两个作用:“避免大数据的复制” 和 “共享”。
开发语言·c++
用户4488466710601 天前
.NET 进阶 —— 深入理解线程(3)ThreadPool 与 Task 入门:从手动线程到池化任务的升级
c#·.net
ghie90901 天前
MATLAB 高速公路裂缝检测
开发语言·matlab
Yyyyy123jsjs1 天前
Python 如何做量化交易?从行情获取开始
开发语言·python
violet-lz1 天前
C++ 内存分区详解
开发语言·jvm·c++