谢谢楼主,很方便。
试了一下,制作压缩包需要一点时间,第一次还以为代码没反应呢。所以,在窗口加个标签Label1,加点提示:
e.Form.Controls("Label1").Text = "正在制作升级包,请稍候..."
Application.DoEvents()
e.Form.Controls("Button1").Enabled = False
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)
e.Form.Controls("Label1").Text = "升级包制作完毕."
Application.DoEvents()
e.Form.Controls("Button1").Enabled = True
Dim Proc As New Process
Proc.File = ProjectPath & "update"
Proc.Start()