[HELP]Updater[Solved]

Posts 1–9 of 9 · Page 1 of 1
[HELP]Updater[Solved]
I know there are lots for tuts here for an updater, but they just check if its updated or not.

I want it to check if its updated or not, if its not, it will download it

Can you give me a tut? /yea

Thanks!

P.S. Congratz to NextGen1 for becoming a mod
Tip: Net.WebClient
Well how much more do you need? Just do what all the tuts say and then if it's out of date, download the new file from the internet (it'll need to be a static address or have a online reader or some crap)

Then just do

[php]
If OutOfDate = True then
My.Computer.Network.DownloadFile("www.yoursire.com/NewVersion.zip")
End if
[/php]

or something like that.
What you need:

  • Button
  • Progressbar(Make it show text, see properties)
  • Label
  • Backgroundworker


[php]#Region "Declarations"
'new webclient to for downloading
WithEvents webC As New Net.WebClient

Private apppath As String = Application.StartupPath & "\"
Private filename As String
'avoid the same filename twice
Private i As Integer = 1

'received/total bytes
Private total, current As Integer

'links
Private Const _version As String = "http://version.txt"
Private Const _FileToDL As String = "http://Recorder.exe"
Private Const _log As String = "http://changelog.txt"

#End Region

#Region "Download/Progress"

Private Sub cmdDownload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDownload.Click
If cmdDownload.Text = "Download" Then
bgwDownload.RunWorkerAsync()
Else
Process.Start(filename)
Application.Exit()
Me.Close()
End If
End Sub

Private Sub webC_DownloadFileCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles webC.DownloadFileCompleted
MsgBox("Download complete." & vbNewLine & vbNewLine _
& "Saved at: " & filename)

cmdDownload.Text = "Start Recorder"
cmdDownload.Enabled = True
End Sub

Private Sub webC_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles webC.DownloadProgressChanged
current = e.BytesReceived 'bytes i dled already
total = e.TotalBytesToReceive 'total bytes it has to dl

If total <> current Then
cmdDownload.Enabled = False
End If

pbProgress.Value = e.ProgressPercentage
pbProgress.Text = CInt(current / 1024) & "/" & CInt(total / 1024) & " KB received | " & e.ProgressPercentage & " %"
End Sub

Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles bgwDownload.DoWork
webC.DownloadFileAsync(New Uri(_FileToDL), filename)
End Sub

#End Region

#Region "Startup"

Private Sub UpdateApp_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Control.CheckForIllegalCrossThreadCalls = False

Dim cl As New Threading.Thread(AddressOf changelog)
cl.Start()

lblCurV.Text &= Application.ProductVersion

Do While IO.File.Exists(apppath & "Recorder_Updated - " & i & ".exe")
i += 1
Loop

filename = apppath & "Recorder_Updated - " & i & ".exe"
End Sub

Private Sub changelog()
txtChangelog.Text = loadPage(_log)
End Sub

Private Sub newversion()
lblNewV.Text &= loadPage(_version)
End Sub

Private Sub UpdateApp_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
Dim checkv As New Threading.Thread(AddressOf newversion)
checkv.Priority = Threading.ThreadPriority.Highest
checkv.Start()
End Sub

#End Region [/php]

Fully self-written. Taken from my macro-recorder.



Network.Download Choobs
Quote Originally Posted by Blubb1337 View Post

Network.Download Choobs
Lol I use WebClient, but I cbf explaining about adding controls to a form and all that crap so i just said do the old fashioned way of Network.DownloadFile.
Is this solved?
Yea its solved

thanks guys
Okay marked accordingly then.
Posts 1–9 of 9 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us