Hello m Nikunj,
how to make a auto updater in vb.net
i need help
m using 2 files like
updater.exe
project_filename.exe
so how to make
please help...
How to make a Auto updater in vb.net
Page 1 of 16 Replies - 2446 Views - Last Post: 07 August 2014 - 02:34 AM
Replies To: How to make a Auto updater in vb.net
#2
Re: How to make a Auto updater in vb.net
Posted 16 July 2014 - 08:27 AM
A cursory codeplex search yielded this:
https://autoupdaterd...t.codeplex.com/
What else have you looked into?
https://autoupdaterd...t.codeplex.com/
What else have you looked into?
#3
Re: How to make a Auto updater in vb.net
Posted 16 July 2014 - 06:50 PM
i have code vb.net
this is the code
in this code no errors but if run this program show me messagebox
this is the code
Private Sub CheckForUpdates_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim cmdLineParams As String() = GetCommandLineArgs() If cmdLineParams.Length = 7 Then appurl = cmdLineParams(1) & cmdLineParams(3) apppath = cmdLineParams(2) appname = cmdLineParams(3) appversion = cmdLineParams(4) versioncheckurl = cmdLineParams(5) uri = New Uri(versioncheckurl) AddHandler webclient.DownloadFileCompleted, AddressOf webclient_dlcomplete AddHandler webclient.DownloadProgressChanged, AddressOf webclient_dlprogresschanged Else MessageBox.Show("Incorrect Parameter Count", "Parameter error") Me.Close() End If End Sub
in this code no errors but if run this program show me messagebox
MessageBox.Show("Incorrect Parameter Count", "Parameter error")
#4
Re: How to make a Auto updater in vb.net
Posted 17 July 2014 - 07:05 AM
If so, that's because your condition in your if statement is not met.
If cmdLineParams.Length = 7 ThenBy equaling it to 7 means that the length of the cldLineParams need to be 7 in order for the if statement to remain true. If its not = to 7, you will run into the else condition. Use condition operators. >= 7 so your statement is not required to equal a specific integer. Also this might be helpful? Link - Self Updating Application
#5
Re: How to make a Auto updater in vb.net
Posted 18 July 2014 - 08:55 PM
Code To Look For A Up Date
Code To Downlode
Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("https://dl.dropboxusercontent.com/u/153282115/updateserver/info/versionlookup/newestve rsion.version") Dim response As System.Net.HttpWebResponse = request.GetResponse() Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream()) Dim currentversion As String = My.Settings.currentversion Dim newestversion As String = sr.ReadToEnd() If newestversion.Contains(currentversion) Then Run() Else update() End If
Code To Downlode
Private WithEvents httpclient As WebClient Dim url As String = "https://dl.dropboxusercontent.com/u/153282115/updateserver/dl/core" Dim BasePath As String = My.Computer.FileSystem.SpecialDirectories.MyDocuments Dim savepath As String = BasePath & "\hub\" Dim filenames As String = savepath & "list.txt" Private Sub download() Dim sr As New IO.StreamReader(filenames) Dim line As String = sr.ReadLine() Dim req As Net.WebRequest Dim resp As IO.Stream Dim out As IO.BinaryWriter Do While line IsNot Nothing req = Net.HttpWebRequest.Create(url & line) resp = req.GetResponse().GetResponseStream() Me.Label1.Text = "downloding:" & line out = New IO.BinaryWriter(New IO.FileStream(savepath & line, IO.FileMode.OpenOrCreate)) Dim buf(4096) As Byte Dim k As Int32 = resp.Read(buf, 0, 4096) Do While k > 0 out.Write(buf, 0, k) k = resp.Read(buf, 0, 4096) Loop resp.Close() out.Close() line = sr.ReadLine() Loop Run() End Sub
#6
Re: How to make a Auto updater in vb.net
Posted 19 July 2014 - 06:54 AM
You should specify the file size of your actual updated file and replace the 0 with the file size value instead. If it where me, I'd make my life easy and use the WebClient Download event as my friend. And ditch this:
Do While k > 0 out.Write(buf, 0, k) k = resp.Read(buf, 0, 4096) LoopYou should use the download event handler in the webclient to download the file for you. And use the Download progress changed event to see when you've downloaded the full file.
Dim MainFileSize As Integer Dim MainFileSizeNeeded As Integer Private Sub downloadFile1_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles downloadFile1.DownloadProgressChanged Try If e.BytesReceived = e.TotalBytesToReceive Then MainFileSize = CInt(e.BytesReceived) MainFileSizeNeeded = CInt(e.TotalBytesToReceive) 'This gives you the current file size and how much its downloaded so far. 'If e.BytesReceived = e.TotalBytesToReceive Then You have the file and its 'Downloaded fully and successfully. Then you can begin replacing the other 'old files with these new ones. I've used Cint, to convert from long to integer. 'From this point, you can begin your update. Ie. Copying the new file to the 'installation folder. You will need admin rights for your app to do that for Win XP or after. End If Catch ex As Exception End Try End SubTo run it:
Dim RunDownload As New Threading.Thread(AddressOf Download) 'You will need to edit this to your liking. RunDownload.Start()You also need to add the event parameters and handler back to your Download() Sub. Use the classes and handlers that are available to you, rather than writing your own logic for what is not needed in this case. Hope it helps.
This post has been edited by Sheepings: 19 July 2014 - 07:33 AM
#7
Re: How to make a Auto updater in vb.net
Posted 07 August 2014 - 02:34 AM
Thanks All
Page 1 of 1