{Tut} How to Make An Auto Updater

Mets08123 Jan 18, 2011

  1. Me

    Mets08123 Newbie BANNED
    0/47

    Joined:
    Nov 6, 2010
    Messages:
    15
    Likes Received:
    3
    Trophy Points:
    0
    Gender:
    Male
    Console:
    Xbox
    This is not the best auto updater but it gets the job done :D

    Step 1:
    Just Add A Text Box Anywhere

    Step 2:
    Double Click the Form and add this code about Public Class (name of form)
    Code:
    Imports System.IO
    Imports System.Xml
    Imports System.Net
    Step 3:
    Add This Code under form load
    Code:
            If getXMLValue(TextBox1.Text, "latestVersion") = "2.7.0.0" Then 'Change 2.7.0.0 to the assembly version of your app'
                MsgBox("No Update Found", MsgBoxStyle.Information, "No Update")
                Return
            Else
                If MessageBox.Show("Update found! Would you like to download?", "Update Found", MessageBoxButtons.YesNo) = DialogResult.Yes Then
                    Dim wc As New WebClient()
                    wc.DownloadFile("http://yoursitehere.com/nameofapp.exe", "Name of App" )
                End If
            End If
            Return
        End Sub
        Private Function getXMLValue(ByVal update As String, ByVal setting As String) As String
            Dim xmlr As XmlReader = XmlReader.Create("http://www.yoursitehere.com/version.xml")
            xmlr.Read()
            xmlr.ReadToFollowing(setting)
    
            Dim value As String = xmlr.ReadString()
            xmlr.Close()
    
            Return value
        End Function
    
    Delete the extra End Sub if you get an error
    Step 4:
    Go to x10hosting.com and sign up for a hosting account.
    Then, login into cPanel and go to File Manager.
    Then, click upload and upload the NEWEST .exe of your app.

    Step 5 (Making the XML File):
    Open a new notepad file and add this code to it:
    Code:
      <?xml version="1.0" encoding="UTF-8"?>
    <checkForUpdate>
    <latestVersion>1.0.0.0</latestVersion>
    </checkForUpdate>
    The version number doesn't matter. Now go to file>>>>save as... and make sure you have all files selected and name it version.xml

    Step 5:
    Upload the version.xml file to x10hosting

    Your DONE!

    MUST READ!​

    Now in visual basics go to your apps properties>>>Assembly Information>> and change Assembly Version and File Version to a NEW version. So if your old one was version 2.6.0.0 you MUST CHANGE THIS TO 2.7.0.0 and so on FOR THE AUTO UPDATER TO WORK!

    Now each time you want to update your app you MUST change the assembly information to the LATEST version. For example the assembly I used the version number was 2.7.0.0 so that was the latest version. EVERYTIME you want to release a new version you MUST change the version number.

    Now when you want to make an update you have to change the .xml file to the NEWEST version number. Do this by going into cPanel>>>File Manager>>right click version.xml>>>code edit>>> then just change the to the NEWEST version of your app!
    Also, you must also upload the NEWEST version of your app.exe


    Any questions or comments just post :D

    Source: Mets08123's Auto Updater.zip
     
  2. Ji

    JizzaBeez The One and Only
    0/47

    Joined:
    Nov 15, 2009
    Messages:
    384
    Likes Received:
    136
    Trophy Points:
    0
    Gender:
    Male
    Location:
    Cerebral Cortex.
    Console:
    Xbox
    It really doesn't have to be an XML file that holds the version info... It's much easier to just put the version in a text file and have your WebClient read the text file as a string. If the string > then your current version then download the update! You would need to have your update .exe file and the update .txt file hosted.
     
  3. Me

    Mets08123 Newbie BANNED
    0/47

    Joined:
    Nov 6, 2010
    Messages:
    15
    Likes Received:
    3
    Trophy Points:
    0
    Gender:
    Male
    Console:
    Xbox
    that's how this works. you just change the .xml on x10hosting. you don't have to make a new one.. then just upload the newest .exe
     
  4. ghostcom

    ghostcom Newbie
    0/47

    Joined:
    Jan 13, 2011
    Messages:
    82
    Likes Received:
    1
    Trophy Points:
    0
    Location:
    Office Space - Cube 15
    Console:
    Xbox
    Plus, most real world application (enterprise/corporate scale) do their update pushes via xml and database application management. I.E., a web service/client is used to obtain the xml and compare the versions of the current app and the next release candidate. If an update is necessary, the app is downloaded and storerd as a blob in a database, then on the next system/app startup (usually forced on an update), the Blob is written to the filesystem and the old application is deleted (but a copy remains in the database as a sort of previous version cache).

    I'd say while it is an extremely simple auto-updater, the base logic is the same on an enterprise scale and good "for the future" practice if you decide to go into the real world as a software engineer :p...although I cringe at the VB. Only legacy code uses VB pretty much.
     

Share This Page

Close