Automatic Updates

Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
108 posts Page 7 of 11
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4389
Joined: Tue Aug 04, 2009 1:47 am

Re: Automatic Updates
CodenStuff
Hello V-Light,

The 2 html files are for the updated exe file location and the new version number.

Inside updatedownload.html you need to write the location of your updated exe file on your webhost like:

http://www.YOURSITE.com/ThisIsMyUpdated.exe

And in version.html you need to write the new version number like:

v1.2

Then upload them both to your webhost.
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
Axel
Coding God
Coding God
Posts: 1928
Joined: Sun Jun 27, 2010 9:15 pm

Re: Automatic Updates
Axel
hey codenstuff ,
(sorry for the late bump :D )
but i would just download the .exe and not the whole folder :D for example , you have the gecko webbrowser (21megabyte for the gecko folder) then i would just download the exe and replace it :D if you have new components in it then just zip and unzip:D
a few ideas? (A)
http://vagex.com/?ref=25000
User avatar
Bogoh67
VIP - Site Partner
VIP - Site Partner
Posts: 656
Joined: Sun Apr 18, 2010 8:20 pm

Re: Automatic Updates
Bogoh67
pretty cool although there are easier to do it
Vikhedgehog
VIP - Donator
VIP - Donator
Posts: 812
Joined: Fri Nov 05, 2010 6:24 pm

Re: Automatic Updates
Vikhedgehog
Thanks! I understand now how it works! Now my programs will get up to date with your help! Thanks! clapper; cooll; clapper; cooll;
User avatar
XTechVB
VIP - Site Partner
VIP - Site Partner
Posts: 727
Joined: Thu May 20, 2010 10:32 am

Re: Automatic Updates
XTechVB
cool i'm gonna use this
You can find me on Facebook or on Skype mihai_92b
User avatar
bisnes_niko
Serious Programmer
Serious Programmer
Posts: 409
Joined: Tue Aug 24, 2010 1:21 pm

Re: Automatic Updates
bisnes_niko
Incase you forgot that long-ish gethttprequest; you can use a WebClient with DownloadString("url")

dim strVer as String = WebClient1.DownloadString("www.yoursite.com/updates/ver.txt")

And, incase your "something.html" is at private FTP Folder, you might wanna add piece of code to prevent error "Not logged in"

WebClient1.Credentials = New Net.NetworkCredential("username", "password")

That's just one of the many ways...

If you are not using DownloadFileASync(), then you should give try for Multi-Threading to remove the freezing of your app... for an example you're using My.computer.network.Downloadfile(), it will freeze your app till it downloaded the program.
User avatar
thapriceless
Just Registered
Just Registered
Posts: 4
Joined: Wed Oct 27, 2010 4:07 am

Re: Automatic Updates
thapriceless
great tut learned a lot thanks
User avatar
M1z23R
VIP - Donator
VIP - Donator
Posts: 622
Joined: Tue Sep 28, 2010 4:55 pm

Re: Automatic Updates
M1z23R
You don't have to put richtextbox on the form, nor you have to make it invisible, just add this at the beginning of the code :
"Dim RichTextBoxForUpdate as NEW richtextbox"
and that is all xD
you can call it what ever you want, but in the following code, use the same !
User avatar
HarrySeddon
Just Registered
Just Registered
Posts: 6
Joined: Tue Jan 11, 2011 4:18 pm

Re: Automatic Updates
HarrySeddon
This is what i needed
User avatar
marve25
VIP - Donator
VIP - Donator
Posts: 40
Joined: Sun Sep 20, 2009 3:47 pm

Re: Automatic Updates
marve25
i need help, when i run the updater then it says "There was a problem downloading the update, please try again later."
i have tried running it as administrator, but it only shows the same.

and im a little confused were to put the two URLs.

heres the code
Code: Select all
Imports System.Net.webclient
Imports System.IO
Imports System.net
Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim url As String = "https://sites.google.com/site/tvilsommeforetak/software/updatedownload.html"
        Dim pageRequest As HttpWebRequest = CType(WebRequest.Create(url), HttpWebRequest)
        Dim pageResponse As WebResponse = pageRequest.GetResponse()
        Dim page As String = ""
        Using r As New StreamReader(pageResponse.GetResponseStream())
            page = r.ReadToEnd()
        End Using
        Dim WebUpdate As System.Net.WebClient
        WebUpdate = New System.Net.WebClient()
        AddHandler WebUpdate.DownloadProgressChanged, AddressOf OnDownloadProgressChanged
        AddHandler WebUpdate.DownloadFileCompleted, AddressOf OnFileDownloadCompleted
        WebUpdate.DownloadFileAsync(New Uri(page), Application.StartupPath & "\Updated.exe")
    End Sub
    Private Sub OnDownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs)
        Dim totalSize As Long = e.TotalBytesToReceive
        Dim downloadedBytes As Long = e.BytesReceived
        Dim percentage As Integer = e.ProgressPercentage
        ProgressBar1.Increment(percentage)
    End Sub
    Private Sub OnFileDownloadCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs)
        If e.Cancelled Then
        ElseIf Not e.Error Is Nothing Then
            MsgBox("There was a problem downloading the update,  please try again later.")
        Else
            If My.Computer.FileSystem.FileExists(Application.StartupPath & "\Tick-Tock.exe") Then
                My.Computer.FileSystem.DeleteFile(Application.StartupPath & "\Tick-Tock.exe", FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.DeletePermanently)
            End If
            If My.Computer.FileSystem.FileExists(Application.StartupPath & "\Updated.exe") Then
                My.Computer.FileSystem.RenameFile(Application.StartupPath & "\Updated.exe", "Tick-Tock.exe")
            End If
            Timer1.Enabled = True
        End If
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If My.Computer.FileSystem.FileExists(Application.StartupPath & "\Tick-Tock.exe") Then
            System.Diagnostics.Process.Start(Application.StartupPath & "\Tick-Tock.exe")
            Me.Close()
        End If
    End Sub
End Class
108 posts Page 7 of 11
Return to “Tutorials”