• 桌面程序自动更新程序(C# )


    更新程序是比较本地与局域网另一台机上的UpdateList.xml文件中Version差异来更新的.
    如果Version不一样,会调用更新
    更新程序检查Files下面各个File的ver如果本地与远程不一样, 或没有则会更新本地的文件.
    在主程序开始时调一CheckUpdate 一时内打开多次只会提示一次
    private static void CheckUpdate()
    {
        try
        {
            XmlDocument docLocal = new XmlDocument();
            XmlDocument docServer = new XmlDocument();
            docLocal.Load("UpdateList.xml");
            string strServerXmlPath = docLocal.SelectSingleNode("/AutoUpdater/Updater/ServerXml").Attributes["Name"].InnerText;
            docServer.Load(strServerXmlPath);//载入远程的xml
            string strLocalVersion = docLocal.SelectSingleNode("/AutoUpdater/Updater/Version").InnerText;
            string strServerVersion = docServer.SelectSingleNode("/AutoUpdater/Updater/Version").InnerText;
            string strLocalTime = docLocal.SelectSingleNode("/AutoUpdater/Updater/LastUpdateTime").Attributes["Time"].InnerText;
            TimeSpan span = DateTime.Now - DateTime.Parse(strLocalTime);
            if (strLocalVersion != strServerVersion && span.Hours > 1)
            {
                if (MessageBox.Show("发现更新, 是否更新?", "更新提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.OK)
                {
                    Process.Start("AutoUpdate.exe");
                    Process.GetCurrentProcess().Kill();
                }
            }
            else
            {
                //修改下最后更新时间 退出 免得再次打开程序提示更新
                docLocal.SelectSingleNode("/AutoUpdater/Updater/LastUpdateTime").Attributes["Time"].InnerText = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
                docLocal.Save("UpdateList.xml");
            }
        }
        catch { }
    }

    自动更新程序源码 

  • 相关阅读:
    生成15位或者4位随机数 (主要用于微信支付订单号)
    支付签名 MD5Util 排序工具类
    JVM垃圾回收(GC)
    JVM内存区域
    Java实现经典七大经典排序算法
    Java设计模式之装饰者模式
    Java设计模式之单例模式
    提前批笔试一道算法题的Java实现
    Java设计模式之工厂模式
    文件上传和下载
  • 原文地址:https://www.cnblogs.com/barrysgy/p/2294596.html
Copyright © 2020-2023  润新知