Click here to Skip to main content
14,034,599 members
Click here to Skip to main content
Add your own
alternative version


35 bookmarked
Posted 16 Jul 2007
Licenced CPOL

Download Manager for Application Updates

, 16 Jul 2007
Rate this:
Please Sign up or sign in to vote.
This article describes how to build a component for managing download files of a program.


As a .NET developer, for implementing a project that will check on a web server for updates, I use Microsoft "ClickOnce". But because this application runs on Windows locked, I decided to develop one myself.


The principal components of this project are:

  1. An XML file that resides on the web server
  2. Component Update
  3. Client for the component update
  4. The principal program

The XML file is structured this way:

<?xml version="1.0" encoding="utf-8" ?>
    <update id="1" dtUpdate="2007_06_01" version="1_0_0_1" RestartFastBet="False">
            <file remote="http://youWebServer/fastbet_Download/1_0_0_1/fastbet.exe" 

                      locale="fastbet.exe" MustStart="False"></file>
            <config key="Last_Update" section="Update" value="2007_06_01"></config>
    <update id="2" dtUpdate="2007_07_02" version="1_0_0_1" RestartFastBet="False">
            <config key="Last_Update" section="Update" value="2007_07_02"></config>

Every tag update is a new version of the program. The date of a version is in the attribute dtUpdate inside the update node, so if a version of a program (that I match with the key getSetting("FastBet", "Update", "LastUpdate")) is old, the first thig that I do is to download the file and metadata.

The file of the new version is found in the attributes inside the <file> node. The attribute remote is the URI where the file must be downloaded, and locale is the path where the file will be copied on the local machine. Metadata is represented with the node <config>. The metadata section has the same attributes used to save a key on the Registry:

Savesetting("Fastbet", "[section]","[key]", "[value]")

Below we can see how this works!

Using the code

In the component update part, I use the class Update. In this class, there is a method that will get the XML file and it will be loaded in the XMLDoc property:

Public Sub CheckForUpdate(ByVal sUrl As String) 
    Dim Request As HttpWebRequest = CType(WebRequest.Create(sUrl), HttpWebRequest) 
    Dim response As HttpWebResponse = CType(Request.GetResponse, HttpWebResponse) 
    Dim responseStream As StreamReader = New StreamReader

    Dim output As String = responseStream.ReadToEnd()
End Sub

Function Main()
        Dim bytesProcessed As Integer = 0
        Dim remoteStream As Stream = Nothing
        Dim localeStream As Stream = Nothing
        Dim response As HttpWebResponse = Nothing
        Dim request As HttpWebRequest = CType(WebRequest.Create(remoteFile), HttpWebRequest)
        response = request.GetResponse
        If Not response Is Nothing Then
            remoteStream = response.GetResponseStream
            localeStream = File.Create(LocaleFile)
            Dim buffer(1024) As Byte
            Dim Bytesread As Integer
                Bytesread = remoteStream.Read(buffer, 0, buffer.Length)
                localeStream.Write(buffer, 0, Bytesread)
                bytesProcessed += Bytesread
                If Bytesread = 0 Then Exit Do
            If Not response Is Nothing Then response.Close()
            If Not remoteStream Is Nothing Then remoteStream.Close()
            If Not localeStream Is Nothing Then localeStream.Close()
        End If
        Return bytesProcessed


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Web Developer
Italy Italy
I have played various roles in IT since around 1998 when I began writing microsoft Access forms. I then moved to mainly coding in Visual Basic around 1999. Since the release of .net I have been mainly working in .net focusing in and very massive use of SQL Server.
Now i working for italian bookmaker like Web Developer on distribuited applicaitons.

You may also be interested in...


Comments and Discussions

GeneralMy vote of 5 Pin
smartsabbas5217-Aug-10 1:28
membersmartsabbas5217-Aug-10 1:28 
Generali can't either Pin
irfan aza9-Nov-09 19:20
memberirfan aza9-Nov-09 19:20 
GeneralCode Pin
vunhuthang5-Dec-07 20:35
membervunhuthang5-Dec-07 20:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web05 | 2.8.190423.1 | Last Updated 16 Jul 2007
Article Copyright 2007 by alex_pa_72
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid