首页

winform版本自动升级C#

c#

2020-6-27

源码为解决独立开发人开发C/S模式版本升级问题,源码解决了通过检索本地版本与服务器版本是否有差异,如果有则进行版本升级,升级完成后自动打开主程序,大家一看就明白

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Update;

namespace ExceTransforCsv
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            if (checkUpdateLoad())
            {
                Application.Exit();
                return;
            }
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
        public static bool checkUpdateLoad()
        {
            bool result = false;
            SoftUpdate app = new SoftUpdate(Application.ExecutablePath, "ExceTransforCsv");
            try
            {
                if (app.IsUpdate && MessageBox.Show("检查到新版本,是否更新?", "版本检查", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    string path = Application.StartupPath.Replace("program", "");
                    System.Diagnostics.Process process = new System.Diagnostics.Process();
                    process.StartInfo.FileName = "autoUpdate.exe";
                    process.StartInfo.WorkingDirectory = path;//要掉用得exe路径例如:"C:\windows";               
                    process.StartInfo.CreateNoWindow = true;
                    process.Start();

                    result = true;
                }
                else
                {
                    result = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                result = false;
            }
            return result;
        }
    }
}

资源下载此资源下载价格为3D币(VIP免费),请先
资源文件列表
TestDemo/autoUpdate/autoUpdate.csproj , 4060
TestDemo/autoUpdate/bin/Debug/autoUpdate.exe , 10240
TestDemo/autoUpdate/bin/Debug/autoUpdate.pdb , 22016
TestDemo/autoUpdate/bin/Debug/autoUpdate.vshost.exe , 11600
TestDemo/autoUpdate/bin/Debug/autoUpdate.vshost.exe.manifest , 490
TestDemo/autoUpdate/bin/Debug/COMMON.dll , 4096
TestDemo/autoUpdate/bin/Debug/COMMON.pdb , 7680
TestDemo/autoUpdate/bin/Debug/Update.dll , 8192
TestDemo/autoUpdate/bin/Debug/Update.pdb , 17920
TestDemo/autoUpdate/bin/Debug/zipfile.dll , 464384
TestDemo/autoUpdate/Form1.cs , 4326
TestDemo/autoUpdate/Form1.Designer.cs , 3143
TestDemo/autoUpdate/Form1.resx , 6011
TestDemo/autoUpdate/obj/x86/Debug/autoUpdate.csproj.FileListAbsolute.txt , 826
TestDemo/autoUpdate/obj/x86/Debug/autoUpdate.csproj.GenerateResource.Cache , 975
TestDemo/autoUpdate/obj/x86/Debug/autoUpdate.csprojResolveAssemblyReference.cache , 14303
TestDemo/autoUpdate/obj/x86/Debug/autoUpdate.exe , 10240
TestDemo/autoUpdate/obj/x86/Debug/autoUpdate.Form1.resources , 180
TestDemo/autoUpdate/obj/x86/Debug/autoUpdate.pdb , 22016
TestDemo/autoUpdate/obj/x86/Debug/autoUpdate.Properties.Resources.resources , 180
TestDemo/autoUpdate/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache , 6402
TestDemo/autoUpdate/Program.cs , 491
TestDemo/autoUpdate/Properties/AssemblyInfo.cs , 1352
TestDemo/autoUpdate/Properties/Resources.Designer.cs , 2872
TestDemo/autoUpdate/Properties/Resources.resx , 5612
TestDemo/autoUpdate/Properties/Settings.Designer.cs , 1097
TestDemo/autoUpdate/Properties/Settings.settings , 249
TestDemo/COMMON/bin/Debug/COMMON.dll , 4096
TestDemo/COMMON/bin/Debug/COMMON.pdb , 7680
TestDemo/COMMON/COMMON.csproj , 2306
TestDemo/COMMON/CommonMethod.cs , 201
TestDemo/COMMON/obj/Debug/COMMON.csproj.FileListAbsolute.txt , 208
TestDemo/COMMON/obj/Debug/COMMON.dll , 4096
TestDemo/COMMON/obj/Debug/COMMON.pdb , 7680
TestDemo/COMMON/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache , 5664
TestDemo/COMMON/Properties/AssemblyInfo.cs , 1344
TestDemo/ExceTransforCsv/bin/Debug/COMMON.dll , 4096
TestDemo/ExceTransforCsv/bin/Debug/COMMON.pdb , 7680
TestDemo/ExceTransforCsv/bin/Debug/ExceTransforCsv.exe , 17408
TestDemo/ExceTransforCsv/bin/Debug/ExceTransforCsv.pdb , 36352
TestDemo/ExceTransforCsv/bin/Debug/ExceTransforCsv.vshost.exe , 11600
TestDemo/ExceTransforCsv/bin/Debug/ExceTransforCsv.vshost.exe.manifest , 490
TestDemo/ExceTransforCsv/bin/Debug/ICSharpCode.SharpZipLib.dll , 200704
TestDemo/ExceTransforCsv/bin/Debug/NPOI.dll , 1624064
TestDemo/ExceTransforCsv/bin/Debug/NPOI.OOXML.dll , 387072
TestDemo/ExceTransforCsv/bin/Debug/NPOI.OpenXml4Net.dll , 79872
TestDemo/ExceTransforCsv/bin/Debug/NPOI.OpenXmlFormats.dll , 1316864
TestDemo/ExceTransforCsv/bin/Debug/NPOI.xml , 2145032
TestDemo/ExceTransforCsv/bin/Debug/Update.dll , 8192
TestDemo/ExceTransforCsv/bin/Debug/Update.pdb , 17920
TestDemo/ExceTransforCsv/bin/Debug/程序运行顺序/autoUpdate.exe , 10240
TestDemo/ExceTransforCsv/bin/Debug/程序运行顺序/autoUpdate.pdb , 22016
TestDemo/ExceTransforCsv/bin/Debug/程序运行顺序/autoUpdate.vshost.exe , 11600
TestDemo/ExceTransforCsv/bin/Debug/程序运行顺序/autoUpdate.vshost.exe.manifest , 490
TestDemo/ExceTransforCsv/bin/Debug/程序运行顺序/COMMON.dll , 4096
TestDemo/ExceTransforCsv/bin/Debug/程序运行顺序/COMMON.pdb , 7680
TestDemo/ExceTransforCsv/bin/Debug/程序运行顺序/program/COMMON.dll , 4096
TestDemo/ExceTransforCsv/bin/Debug/程序运行顺序/program/COMMON.pdb , 7680
TestDemo/ExceTransforCsv/bin/Debug/程序运行顺序/program/ExceTransforCsv.exe , 17408
TestDemo/ExceTransforCsv/bin/Debug/程序运行顺序/program/ExceTransforCsv.pdb , 36352
TestDemo/ExceTransforCsv/bin/Debug/程序运行顺序/program/ExceTransforCsv.vshost.exe , 11600
TestDemo/ExceTransforCsv/bin/Debug/程序运行顺序/program/ExceTransforCsv.vshost.exe.manifest , 490
TestDemo/ExceTransforCsv/bin/Debug/程序运行顺序/program/ICSharpCode.SharpZipLib.dll , 200704
TestDemo/ExceTransforCsv/bin/Debug/程序运行顺序/program/NPOI.dll , 1624064
TestDemo/ExceTransforCsv/bin/Debug/程序运行顺序/program/NPOI.OOXML.dll , 387072
TestDemo/ExceTransforCsv/bin/Debug/程序运行顺序/program/NPOI.OpenXml4Net.dll , 79872
TestDemo/ExceTransforCsv/bin/Debug/程序运行顺序/program/NPOI.OpenXmlFormats.dll , 1316864
TestDemo/ExceTransforCsv/bin/Debug/程序运行顺序/program/NPOI.xml , 2145032
TestDemo/ExceTransforCsv/bin/Debug/程序运行顺序/program/Update.dll , 8192
TestDemo/ExceTransforCsv/bin/Debug/程序运行顺序/program/Update.pdb , 17920
TestDemo/ExceTransforCsv/bin/Debug/程序运行顺序/Update.dll , 8192
TestDemo/ExceTransforCsv/bin/Debug/程序运行顺序/Update.pdb , 17920
TestDemo/ExceTransforCsv/bin/Debug/程序运行顺序/zipfile.dll , 464384
TestDemo/ExceTransforCsv/ExceTransforCsv.csproj , 4882
TestDemo/ExceTransforCsv/Form1.cs , 15339
TestDemo/ExceTransforCsv/Form1.Designer.cs , 11004
TestDemo/ExceTransforCsv/Form1.resx , 6020
TestDemo/ExceTransforCsv/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache , 6738
TestDemo/ExceTransforCsv/obj/x86/Debug/ExceTransforCsv.csproj.FileListAbsolute.txt , 1332
TestDemo/ExceTransforCsv/obj/x86/Debug/ExceTransforCsv.csproj.GenerateResource.Cache , 975
TestDemo/ExceTransforCsv/obj/x86/Debug/ExceTransforCsv.csprojResolveAssemblyReference.cache , 43070
TestDemo/ExceTransforCsv/obj/x86/Debug/ExceTransforCsv.exe , 17408
TestDemo/ExceTransforCsv/obj/x86/Debug/ExceTransforCsv.Form1.resources , 180
TestDemo/ExceTransforCsv/obj/x86/Debug/ExceTransforCsv.pdb , 36352
TestDemo/ExceTransforCsv/obj/x86/Debug/ExceTransforCsv.Properties.Resources.resources , 180
TestDemo/ExceTransforCsv/Program.cs , 1870
TestDemo/ExceTransforCsv/Properties/AssemblyInfo.cs , 1362
TestDemo/ExceTransforCsv/Properties/Resources.Designer.cs , 2882
TestDemo/ExceTransforCsv/Properties/Resources.resx , 5612
TestDemo/ExceTransforCsv/Properties/Settings.Designer.cs , 1102
TestDemo/ExceTransforCsv/Properties/Settings.settings , 249
TestDemo/ExceTransforCsv/update.xml , 214
TestDemo/TestDemo.sln , 4519
TestDemo/TestDemo.suo , 26112
TestDemo/Update/bin/Debug/COMMON.dll , 4096
TestDemo/Update/bin/Debug/COMMON.pdb , 7680
TestDemo/Update/bin/Debug/Update.dll , 8192
TestDemo/Update/bin/Debug/Update.pdb , 17920
TestDemo/Update/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache , 5720
TestDemo/Update/obj/Debug/Update.csproj.FileListAbsolute.txt , 397
TestDemo/Update/obj/Debug/Update.csprojResolveAssemblyReference.cache , 4940
TestDemo/Update/obj/Debug/Update.dll , 8192
TestDemo/Update/obj/Debug/Update.pdb , 17920
TestDemo/Update/Properties/AssemblyInfo.cs , 1344
TestDemo/Update/SoftUpdate.cs , 6014
TestDemo/Update/Update.csproj , 2510
没有账号? 忘记密码?

社交账号快速登录