嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元微信扫码支付:2 元
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
winform自动升级,主程和附助程序之间的配合升级主程,主要是先开启主程序,判断是否需要升级 ,如果需要升级,启动附助程序升级,再关闭主程序,升级成功后,再开启主程序 关闭附助程序,这样就完成了主程序升级,具体看代码,不多说
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;
}
}
}