资源简介
实现c#开发的winform程序根据程序版本号是否需要更新程序,启动更新程序从服务器下载新版本程序并解压覆盖主程序,运行主程序。

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.IO;
using COMMON;
using Update;
namespace autoUpdate
{
public partial class Form1 : Form
{
[DllImport(“zipfile.dll“)]
public static extern int MyZip_ExtractFileAll(string zipfile string pathname);
public Form1()
{
InitializeComponent();
//清除之前下载来的rar文件
if (File.Exists(Application.StartupPath + “\\Update_autoUpdate.zip“))
{
try
{
File.Delete(Application.StartupPath + “\\Update_autoUpdate.zip“);
}
catch (Exception)
{
}
}
if (Directory.Exists(Application.StartupPath + “\\autoupload“))
{
try
{
Directory.Delete(Application.StartupPath + “\\autoupload“ true);
}
catch (Exception)
{
}
}
//检查服务端是否有新版本程序
checkUpdate();
timer1.Enabled = true;
}
SoftUpdate app = new SoftUpdate(Application.ExecutablePath “ExceTransforCsv“);
public void checkUpdate()
{
app.UpdateFinish += new UpdateState(app_UpdateFinish);
try
{
if (app.IsUpdate)
{
app.Update();
}
else
{
MessageBox.Show(“未检测到新版本!“);
Application.Exit();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
void app_UpdateFinish()
{
//解压下载后的文件
string path = app.FinalZipName;
if (File.Exists(path))
{
//后改的 先解压滤波zip植入ini然后再重新压缩
string dirEcgPath = Application.StartupPath + “\\“ + “autoupload“;
if (!Directory.Exists(dirEcgPath))
{
Directory.CreateDirectory(dirEcgPath);
}
//开始解压压缩包
MyZip_ExtractFileAll(path dirEcgPath);
try
{
//复制新文件替换旧文件
DirectoryInfo TheFolder = new DirectoryInfo(dirEcgPath);
foreach (FileInfo NextFile in TheFolder.GetFiles())
{
File.Copy(NextFile.FullName Application.StartupPath + “\\program\\“ + NextFile.Name true);
}
Directory.Delete(dirEcgPath true);
File.Delete(path);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4096 2018-12-17 10:20 COMMON\bin\Debug\COMMON.dll
文件 7680 2018-12-17 10:20 COMMON\bin\Debug\COMMON.pdb
文件 2306 2018-07-17 16:53 COMMON\COMMON.csproj
文件 201 2018-07-17 16:45 COMMON\CommonMethod.cs
文件 456 2018-12-17 10:20 COMMON\obj\Debug\COMMON.csproj.FileListAbsolute.txt
文件 4096 2018-12-17 10:20 COMMON\obj\Debug\COMMON.dll
文件 7680 2018-12-17 10:20 COMMON\obj\Debug\COMMON.pdb
文件 5674 2018-12-26 14:43 COMMON\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 1344 2018-07-17 16:44 COMMON\Properties\AssemblyInfo.cs
文件 4096 2018-12-17 10:20 ExceTransforCsv\bin\Debug\COMMON.dll
文件 7680 2018-12-17 10:20 ExceTransforCsv\bin\Debug\COMMON.pdb
文件 17408 2018-12-18 15:25 ExceTransforCsv\bin\Debug\ExceTransforCsv.exe
文件 40448 2018-12-18 15:25 ExceTransforCsv\bin\Debug\ExceTransforCsv.pdb
文件 11600 2018-12-26 14:43 ExceTransforCsv\bin\Debug\ExceTransforCsv.vshost.exe
文件 490 2018-04-12 07:35 ExceTransforCsv\bin\Debug\ExceTransforCsv.vshost.exe.manifest
文件 200704 2017-04-30 14:19 ExceTransforCsv\bin\Debug\ICSharpCode.SharpZipLib.dll
文件 1624064 2013-03-06 07:17 ExceTransforCsv\bin\Debug\NPOI.dll
文件 387072 2013-03-06 07:17 ExceTransforCsv\bin\Debug\NPOI.OOxm
文件 79872 2013-03-06 07:17 ExceTransforCsv\bin\Debug\NPOI.Openxm
文件 1316864 2013-03-06 07:17 ExceTransforCsv\bin\Debug\NPOI.Openxm
文件 2145032 2013-03-06 07:13 ExceTransforCsv\bin\Debug\NPOI.xm
文件 8192 2018-12-17 10:20 ExceTransforCsv\bin\Debug\Update.dll
文件 19968 2018-12-17 10:20 ExceTransforCsv\bin\Debug\Update.pdb
文件 10240 2018-07-17 16:53 ExceTransforCsv\bin\Debug\程序运行顺序\autoUpdate.exe
文件 22016 2018-07-17 16:53 ExceTransforCsv\bin\Debug\程序运行顺序\autoUpdate.pdb
文件 11600 2018-07-17 16:41 ExceTransforCsv\bin\Debug\程序运行顺序\autoUpdate.vshost.exe
文件 490 2018-04-12 07:35 ExceTransforCsv\bin\Debug\程序运行顺序\autoUpdate.vshost.exe.manifest
文件 4096 2018-07-17 16:53 ExceTransforCsv\bin\Debug\程序运行顺序\COMMON.dll
文件 7680 2018-07-17 16:53 ExceTransforCsv\bin\Debug\程序运行顺序\COMMON.pdb
文件 4096 2018-07-17 16:53 ExceTransforCsv\bin\Debug\程序运行顺序\program\COMMON.dll
............此处省略116个文件信息
相关资源
- 超市进销存管理系统 Sqlserver 数据库文
- asp.net C#购物车源代码
- C#实时网络流量监听源码
- C#百度地图源码
- Visual C#.2010从入门到精通配套源程序
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
- C#自定义控件
- 基于c#的实验室设备管理系统621530
- C# 使用ListView控件实现图片浏览器(源
评论
共有 条评论