Imports System.Windows.Forms
Imports System.Xml
Imports System.IO
Public Class updateFRM
Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
System.Diagnostics.Process.Start("http://game-droid.co.cc/update")
Me.Close()
End Sub
Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
Me.Close()
End Sub
Private Sub updateFRM_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim xmldoc As New XmlDataDocument()
Dim xmlnode As XmlNodeList
Dim i As Integer
Dim str As String
Dim fs As New FileStream(Application.StartupPath + "\localversion.xml", FileMode.Open, FileAccess.Read)
xmldoc.Load(fs)
xmlnode = xmldoc.GetElementsByTagName("version")
For i = 0 To xmlnode.Count - 1
xmlnode(i).ChildNodes.Item(0).InnerText.Trim()
str = xmlnode(i).ChildNodes.Item(0).InnerText.Trim()
localVS.Text = str
Next
serverchk()
version_comp()
updateINFO.ReadOnly = True
End Sub
Sub serverchk()
Dim url As String = "http://game-droid.co.cc/program/bin/serverVS.xml"
Dim web As New Net.WebClient
web.Headers(Net.HttpRequestHeader.UserAgent) = "User"
Try
Dim s As Stream = web.OpenRead(url)
Dim doc As New Xml.XmlDocument
doc.Load(s)
s.Close()
Dim version As String = doc.SelectSingleNode("/version").InnerText
serverVS.Text = version
Catch ex As Exception
MsgBox("Error. The server probably is missing a version file. Error was:" + ex.Message)
End Try
End Sub
Sub version_comp()
If localVS.Text = serverVS.Text = False Then
updateYN.Text = "A new version is available. Click ok to go to the website."
Dim url As String = "http://game-droid.co.cc/program/bin/info.rtf"
Dim web As New Net.WebClient
web.Headers(Net.HttpRequestHeader.UserAgent) = "User"
web.DownloadFile(url, Application.StartupPath + "\bin\temp\info.rtf")
updateINFO.LoadFile(Application.StartupPath + "\bin\temp\info.rtf")
OK_Button.Enabled = True
ElseIf localVS.Text = serverVS.Text = True Then
updateYN.Text = "You have the most up-to-date version"
End If
End Sub
End Class