我遇到了一些问题,无法找到我的Update系统有什么问题。我正在使用XML文件。我正在尝试的是让应用程序读取xml文件以获取更新(如某些新闻系统),并在有新版本时获取更新应用程序。我已经在项目ReadOnly _reader As XmlReader = XmlReader.Create("C:\launchernews.xml")
之上添加了。仍然更新系统不起作用,但新闻系统确实有效。
以下是代码:
Public Sub AutoUpdate()
Dim CurrentVersion As String = My.Application.Info.Version.ToString '--- Change this to Current version, needs changing on every update
Dim ProgramName As String '--- Change this to Your Progran Name
Dim GetVer, GetVerLink As String
Dim GetUpd As Integer
Using _reader
While _reader.Read()
' Check for start elements.
If _reader.IsStartElement() Then
If _reader.Name = "application" Then
Dim attribute As String = _reader("name")
If attribute IsNot Nothing Then
ProgramName = attribute
End If
' Text data.
If _reader.Name = "version" Then
Dim version As String = _reader("name")
If version IsNot Nothing Then
GetVer = version
If _reader.Read() Then
GetVerLink = _reader.Value.Trim()
End If
End If
End If
End If
End If
If GetVer > CurrentVersion Then
GetUpd = MsgBox(ProgramName & " is an old version." & vbCrLf & "New Update is available" & _
vbCrLf & "Current version: " & CurrentVersion & vbCrLf & "Version Avalible: " & _
GetVer & vbCrLf & vbCrLf & "Update Now?", vbYesNo, "Update")
If GetUpd = vbYes Then
Dim sfd As New SaveFileDialog
sfd.FileName = IO.Path.GetFileName(GetVerLink)
If sfd.ShowDialog = True Then
My.Computer.Network.DownloadFile(GetVerLink, sfd.FileName)
End If
End If
Else
MsgBox(ProgramName & " is upto date." & vbCrLf & "Current version: " & CurrentVersion, 0, "Update")
End If
End While
End Using
End Sub
这是XML文件:
<?xml version="1.0" encoding="UTF-8"?>
<Launcher>
<news name="Latest Updates">
We thank you for your patience throughout this update.
</news>
<application name="Launcher">
<version name="1.0.0.0">
</version>
</application>
</Launcher>