.net 程序在线升级

来源:互联网 发布:足球数据分析大师 编辑:程序博客网 时间:2024/05/24 15:36

http://www.cnblogs.com/KnightsWarrior/archive/2010/10/20/1856255.html
http://www.cnblogs.com/stoneniqiu/p/3806558.html
配置IIS http://www.sufeinet.com/thread-291-1-1.html
Apache 用户名和密码验证
http://blog.csdn.net/liushu_it/article/details/18735449
借鉴了圣殿骑士写的dll,更改了下载后删除old文件

  1. 在引用中添加AutoUpdater.dll,代码中添加
Imports KnightsWarriorAutoupdater        '实现自动更新的dll
  1. 服务器端配置文件 AutoupdateService.xml
    下面的代码示例会把文件夹tt以及里面的1.txt文件一起拷贝到客户端中,size为文件大小,并非占用空间,必须写对
<?xml version="1.0" encoding="utf-8"?><updateFiles>    <file  path="1.txt"  url="http://10.*.*.*:8011/SerialWrite/tt/1.txt"  lastver="3.2.1.2" size="8" needRestart="True"  /></updateFiles>
  1. 客户端配置文件 AutoUpdater.config
<?xml version="1.0" encoding="utf-8"?><Config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">  <Enabled>true</Enabled>  <ServerUrl>http://10.*.*.*:8011/SerialWrite/AutoupdateService.xml</ServerUrl>  <UpdateFileList>    <LocalFile path="1.txt" lastver="3.2.1.2" size="8" />  </UpdateFileList></Config>
  1. 更新的代码
'*********************'自动更新程序'*********************Dim bHasError As Boolean = FalseDim autoUpdater As IAutoUpdater = New AutoUpdater()Try    autoUpdater.Update()Catch ex As WebException    MessageBox.Show("连接自动升级服务器出错,请检查网络连接或联系软件提供者。(Connect remote update server fail.)", "更新程序(UPDATE SOFTWRAE)", MessageBoxButtons.OK, MessageBoxIcon.Error)    bHasError = TrueCatch ex As XmlException    MessageBox.Show("服务器上的升级文件(AutoupdateService.xml)出错。(Download the upgrade file error.)", "更新程序(UPDATE SOFTWRAE)", MessageBoxButtons.OK, MessageBoxIcon.Error)    bHasError = TrueCatch ex As Exception    MessageBox.Show("更新程序出错。(An error occurred during the upgrade process.)", "更新程序(UPDATE SOFTWRAE)", MessageBoxButtons.OK, MessageBoxIcon.Error)    bHasError = TrueFinally    If bHasError = True Then        Try            autoUpdater.RollBack()        Catch ex As Exception            MsgBox(ex.Message)        End Try    End IfEnd Try
原创粉丝点击