[VB.NET]Auto Up******

  • Hello Guest! Welcome to ConsoleCrunch, to help support our site check out the premium upgrades HERE! to get exclusive access to our hidden content.
  • Unable to load portions of the website...
    If you use an ad blocker addon, you should disable it because it interferes with several elements of the site and blocks more than just adverts.
  • Read Rules Before Posting Post Virus Scans with every program.

1UP

Member
Oct 9, 2014
24
10
63
Now I'm sure there are more then 1 way to do this (and possibly easier ways) but this is just one way I figured out how to update software with just a text file.

Ive used it for a few projects and did notice some problems with the code, of which I will also go over so you don't end up with a program hanging when you goto use this yourself.

First of all I'll be going over multi-threading and reading a file from the internet and then compare it to what you are currently using.


To get us started:

If you are using a webserver simply making a text file called versionnumber.txt (or call it whatever you want, you'll just need to remember to change the code later on)


We need to set our imports:

Code:
Imports System.Net
Imports System.IO
Imports System.Threading

Our module level variable:

Code:
Private WithEvents _Downloader As WebFileDownloader

Now we are going to make a Sub routine so we can call this at anytime down the road if we need it.
Code:
Public Sub Update()
  Dim prodVersion As String = System.Text.Encoding.ASCII.GetString((webclient.DownloadData("http://www.arenagamerz.com/downloads/launcher/versionNumber.txt")))
  Dim updatelink As String = "http://www.arenagamerz.com/downloads/launcher/arenagamerzLauncher.exe"
  Dim UpdateLocation As String = My.Computer.FileSystem.CurrentDirectory

  'Updater
  If Me.ProductVersion() = prodVersion Then

  Else
  MsgBox("New Update available. Downloading")
  Try


  Try
  _Downloader = New WebFileDownloader
  _Downloader.DownloadFileWithProgress(updatelink, UpdateLocation & GetFileNameFromURL(updatelink))
  Catch ex As Exception
  MessageBox.Show("Error: " & ex.Message)
  End Try
  Catch ex As Exception

  End Try

  End If
  End Sub

This code (when called) will look for the specified filename on whatever server you are trying to get to. In this case we are looking for:
"http://www.arenagamerz.com/downloads/launcher/versionNumber.txt"

Updatelocation is where the updated client will be placed (you can make that anywhere you want, for the sake of this post I just made it the directory where this program is , which will cause a problem with overwritting)

Now there is a piece missing from this which is the function for getfilenamefromURL which will look like this:

Code:
Private Function GetFileNameFromURL(ByVal URL As String) As String
  If URL.IndexOf("/"c) = -1 Then Return String.Empty

  Return "\" & URL.Substring(URL.LastIndexOf("/"c) + 1)
  End Function

This is what is used to get the file name to download.

If you were to do this in FormLoad the program would hang because it's going out to the net to see if the initial file exists, if it doesn't it will take a long time to error out and the form won't appear for a while. So to make it so the form will appear and still do the check we are going to put this Sub in a thread.

Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'Start a new thread for the update Sub
  Dim updateApp As Thread
  updateApp = New Thread(AddressOf Me.Update)
  updateApp.Start()

And that's all there is to it
 
  • Like
Reactions: Lindows

Lindows

Super Moderator
Staff member
Moderator
Community Elite
Community Veteran
Determined Poster
Active Member
Console ID Poster
May 26, 2014
1,526
1,633
418
Did you really make all of these o-o?
 
General chit-chat
Help Users
  • @ QM|T_JinX:
    het bro nice work man
  • @ QM|T_JinX:
    with ?
  • @ EMRR:
    What do you mean? I can't understand "with ?"
  • @ QM|T_JinX:
    you ask can you help me and i said with what can i help you out
  • @ EMRR:
    Can you help me about share my generated CID's? Where can i share it on this website?
  • @ QM|T_JinX:
    you can put it in cid section or ps3 section in general
  • @ EMRR:
    Ok, thanks :)
  • @ QM|T_JinX:
    np bro
  • Chat Bot:
    EMRR has started a new thread called "Working Console ID" in Console ID's.
  • Chat Bot:
    EMRR has started a new thread called "Console ID 1" in Console ID's.
  • Chat Bot:
    wadu is our newest member. Welcome!
  • Chat Bot:
    EMRR has started a new thread called "Console ID 2" in Console ID's.
  • Chat Bot:
    QM|T_JinX has posted a new reply in the thread "Console ID 2".
  • @ lurch6661:
    gold hen out soon
  • Chat Bot:
    Christo has joined the room.
  • @ lurch6661:
    zap
  • @ lurch6661:
    trying to figure out how to run a rpf files
  • @ lurch6661:
    on gta5
  • @ lurch6661:
    i guess there is a way were you can upload real cars \
  • @ QM|T_JinX:
    rpf is a update like / update.rpf
  • @ lurch6661:
    also i cant find dmz
  • @ lurch6661:
    is that not warzone
  • Chat Bot:
    Nazzysam is our newest member. Welcome!
    Chat Bot: Nazzysam is our newest member. Welcome!