把写代码过程重要的代码段珍藏起来,如下的代码内容是关于C# 程序自动升级的的代码。
<?xml version="1.0" encoding="utf-8" ?>
<Content>
<Project id="程序名称" Edition="1.0"> </Project>
</Content>
2、在WinForm应用程序启动的时候,首先访问webservice获取服务器的xml中的版本号,然后获取客户端的xml中的版本号。将两个版本号比较,若服务器中的版本号大,则提示提示可以在线更新应用程序。3、然后客户端自动下载网络上的zip压缩包到本机的指定位置,进行自动解压缩到安装的目录进行覆盖。解压缩完毕之后,用进程打开所解压过的exe文件进行软件安装。同时关闭客户端软件所在的进程。4、注意:升级程序和应用程序都是单独的,应用程序在使用时不能对本身进行升级(覆盖会失败)。具体代码如下:第一部分应用程序如口Program:
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Medicine_ERP;
using DevExpress.XtraEditors;
using System.Xml;
using Anshield_AutoFutures.BaseClase;
namespace Anshield_AutoFutures
{
static class Program
{
private static void LoadMath()
{
string NewEdition = "1.0";
string OldEdition = "1.0";
try
{
NewEdition = webserverClase.getCopyRightCode();
String fileName = Application.StartupPath + "\XMLEdition.xml";
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(fileName);
XmlNode xn = xmlDoc.SelectSingleNode("Content");
XmlNodeList xnl = xn.ChildNodes;
foreach (XmlNode xnf in xnl)
{
XmlElement xe = (XmlElement)xnf;
if (xe.GetAttribute("id") == "jigou_plz")
{
}
break;
}
double newE = double.Parse(NewEdition);
double oldE = double.Parse(OldEdition);
if (newE > oldE)
{
DialogResult dr = XtraMessageBox.Show("发现新的版本是否要更新该软件", "平浪舟现货程序化交易--更新提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
if (dr == Dial