Question How do I make an update feature?

techwiz24

Well-known member
Joined
Jun 2, 2010
Messages
51
Programming Experience
Beginner
I am trying to inpliment an update feature where the program pulls the information from the <version></version> tag in an xml document on the users machine AND on my server, and then prints the values in two labels, and then compares them. If they match, then the update button remains disabled, and a label saying "No update is needed" is also shown. If they don't match, then the label with the no update msg is hidden and the update button is enabled. Once the button is clicked, the program downloads setup.exe form my server and runs it.

I don't know where to start :confused:
 
I changed my scope. What I did now, was just compare versions, if they don't match, enable the update button and download the release notes. If they do match, simply tell the user they have the latest version. When the update button is clicked, they are taken to the update page on the website. Way easier. No matter what I tried, it still threw errors. This works, so I'm happy. Thanks for all those who helped!
VB.NET:
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
 
Back
Top