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

写在前面

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

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

参考官方示例

代码实现

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

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 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>

调用示例

相关推荐

  1. Postman关闭自动更新程序

    2024-02-20 08:06:05       67 阅读
  2. 程序自动更新功能

    2024-02-20 08:06:05       61 阅读
  3. mybatisplus实现自动创建/更新时间

    2024-02-20 08:06:05       60 阅读
  4. python实现自动更新prometheus规则

    2024-02-20 08:06:05       23 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-02-20 08:06:05       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-02-20 08:06:05       101 阅读
  3. 在Django里面运行非项目文件

    2024-02-20 08:06:05       82 阅读
  4. Python语言-面向对象

    2024-02-20 08:06:05       91 阅读

热门阅读

  1. Ubuntu 上安装 GitLab

    2024-02-20 08:06:05       44 阅读
  2. Resolving Low-Level Graphics Issues

    2024-02-20 08:06:05       65 阅读
  3. 爬虫的介绍与使用

    2024-02-20 08:06:05       48 阅读
  4. MACOS上面C/C++获取网卡索引,索引获取网卡接口名

    2024-02-20 08:06:05       49 阅读
  5. zookeeper源码(08)请求处理及数据读写流程

    2024-02-20 08:06:05       41 阅读
  6. uniapp 面试题

    2024-02-20 08:06:05       48 阅读
  7. centos7编译c++碰到的坑

    2024-02-20 08:06:05       53 阅读