Imports System.Xml
Imports System.IO
Imports System.Net
Imports System.Text
Public Class updateFRM
Private Sub updateFRM_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
localVS.Text = "0.7.1"
status.Text = "re-buffering feed"
status.Text = "fetching server version"
serverchk()
status.Text = "comparing"
version_comp()
End Sub
Sub serverchk()
Dim xmldoc As New XmlDataDocument()
Dim xmlnode As XmlNodeList
Dim i As Integer
Dim str As String
Dim fs As String
fs = "http://game-droid.co.cc/program/bin/serverVS.xml"
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()
serverVS.Text = str
Next
End Sub
Sub version_comp()
If localVS.Text = serverVS.Text = False Then
Button1.Enabled = True
updateYN.Text = "Update required. Click Update Now to update"
ElseIf localVS.Text = serverVS.Text = True Then
Button1.Enabled = False
updateYN.Text = "No updates. Please click Cancel"
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
updateYN.Text = "Downloading updates"
Button2.Enabled = False
updateYN.Text = "Checking temporary directory"
If System.IO.Directory.Exists(Application.StartupPath + "\Bin\temp\") Then
updateYN.Text = "directory exists"
ElseIf System.IO.Directory.Exists(Application.StartupPath + "\Bin\temp\") = False Then
updateYN.Text = "directory doesn't exist, creating"
System.IO.Directory.CreateDirectory(Application.StartupPath + "\Bin\temp\")
updateYN.Text = "directory created"
End If
status.Text = "Begining Download"
Dim request As WebRequest
Dim response As WebResponse
Dim reader As Stream
Dim writer As Stream
Dim data(1023) As Byte
Dim count As Integer
Dim total As Integer
Application.DoEvents()
updateYN.Text = "connecting to update server"
request = WebRequest.Create("http://www.game-droid.co.cc/program/bin/setupGD.exe")
response = request.GetResponse()
reader = response.GetResponseStream()
updateYN.Text = "connected, fetching file size"
ProgressBar1.Maximum = CInt(response.ContentLength)
ProgressBar1.Value = 0
total = 0
updateYN.Text = "writing file to temporary directory"
writer = File.Create(Application.StartupPath + "\Bin\temp\setupGD.exe")
While True
count = reader.Read(data, 0, 1024)
If count <= 0 Then
Exit While
End If
writer.Write(data, 0, count)
total += 1024
If total < ProgressBar1.Maximum Then ProgressBar1.Value = total
Application.DoEvents()
End While
reader.Close()
writer.Close()
Button2.Enabled = True
updateYN.Text = "Update Downloaded"
MsgBox("Update downloaded, patch GameDroid Now?", MsgBoxStyle.YesNo, "Update now?")
If MsgBoxResult.Yes Then
System.Diagnostics.Process.Start(Application.StartupPath + "\Bin\temp\setupGD.exe")
Me.Close()
Form1.Close()
subcat_selector.Close()
OptionsForm.Close()
Else
Me.Close()
End If
End Sub
End Class