自动升级需要3个文件,update.txt、update1.zip、update2.zip,如果每次都手动修改update.txt,然后压缩update1.zip、update2.zip很麻烦,还容易出错,为此编写一小段代码,自动完成 以上功能,共享之。
Dim zip As New zipFile
Dim yswj As String = ProjectPath & "update\update2.zip"
Dim yslj As String = ProjectPath & "publish"
zip.Create( yswj )
zip.AddFolder(yslj)
zip.Close()
Dim yswj1 As String = ProjectPath & "update\update1.zip"
Dim yslj1 As String = ProjectPath & "publish\Project"
zip.Create( yswj1 )
zip.AddFolder(yslj1)
zip.Close()
Dim yswj2 As String = ProjectPath & "update\update.txt"
Dim s As String = Format(PublishDate, "yyyy-MM-dd") & "|2014-07-20"
FileSys.WriteAllText( yswj2 , s, False, Encoding.Default)
MessageBox.Show("升级文件制作完毕,请复制到升级文件夹!","温馨提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
注:须在项目文件夹下建立 update文件夹 共勉。
多谢大家捧场,特别感谢5楼热心相助!现将5楼意见整合,共享之!
If FileSys.DirectoryExists(ProjectPath & "update") = False Then
FileSys.CreateDirectory(ProjectPath & "update")
End If
If FileSys.DirectoryExists(ProjectPath & "publish") = True Then
Dim zip As New zipFile
Dim yswj As String = ProjectPath & "update\update2.zip"
Dim yslj As String = ProjectPath & "publish"
zip.Create( yswj )
zip.AddFolder(yslj)
zip.Close()
End If
If FileSys.DirectoryExists(ProjectPath & "publish\Project") = True Then
Dim zip1 As New zipFile
Dim yswj1 As String = ProjectPath & "update\update1.zip"
Dim yslj1 As String = ProjectPath & "publish\Project"
zip1.Create( yswj1 )
zip1.AddFolder(yslj1)
zip1.Close()
End If
Dim yswj2 As String = ProjectPath & "update\update.txt"
Dim s As String = Format(PublishDate, "yyyy-MM-dd") & "|" & Format(CDate(applicationvertion),"yyyy-MM-dd")
FileSys.WriteAllText( yswj2 , s, False, Encoding.Default)
MessageBox.Show("升级文件制作完毕,请复制到升级文件夹!","温馨提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
再次感谢论坛朋友!
此主题相关图片如下:qq截图20140814144222.jpg
此主题相关图片如下:qq截图20140815082153.jpg
开发版文件 【含代码】
[此贴子已经被作者于2014-8-15 17:43:15编辑过]