DLL 下载地址
https://download.youkuaiyun.com/download/letunihao/15805303
http://www.cnblogs.com/KnightsWarrior/archive/2010/10/20/1856255.html
http://www.cnblogs.com/stoneniqiu/p/3806558.html
配置IIS
https://blog.youkuaiyun.com/u011635349/article/details/79972326
https://blog.youkuaiyun.com/zy010101/article/details/86580506
Apache 用户名和密码验证
http://blog.youkuaiyun.com/liushu_it/article/details/18735449
借鉴了圣殿骑士写的dll,更改了下载后删除old文件
配置IIS 的时候,身份认证打开匿名认证就可以了;
生成AutoUpdater.dll 的.net框架要和所写项目的.NET框架一致;
- 在引用中添加AutoUpdater.dll,代码中添加
Imports KnightsWarriorAutoupdater '实现自动更新的dll
- 服务器端配置文件 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>
- 客户端配置文件 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>
- 更新的代码
'*********************
'自动更新程序
'*********************
Dim bHasError As Boolean = False
Dim 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 = True
Catch ex As XmlException
MessageBox.Show("服务器上的升级文件(AutoupdateService.xml)出错。(Download the upgrade file error.)", "更新程序(UPDATE SOFTWRAE)", MessageBoxButtons.OK, MessageBoxIcon.Error)
bHasError = True
Catch ex As Exception
MessageBox.Show("更新程序出错。(An error occurred during the upgrade process.)", "更新程序(UPDATE SOFTWRAE)", MessageBoxButtons.OK, MessageBoxIcon.Error)
bHasError = True
Finally
If bHasError = True Then
Try
autoUpdater.RollBack()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If
End Try