Steve323 (05-27-2010)
This will get the current version info from online.
Form1 Load
[php]
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
WebClient1.DownloadFileAsync(New Uri("https://blahblahblah.com/version.txt"), "version.txt")
End Sub
[/php]
This compares the current version info to the version of the program. If it is lower than the current version info from online, it will try to get the download link of the program.
WebClient1_DownloadFileCompleted
[php]
Private Sub WebClient1_DownloadFileCompleted(ByVal sender As System.Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles WebClient1.DownloadFileCompleted
Dim Read As String = My.Computer.FileSystem.ReadAllText("version.txt")
If Not Read = Application.ProductVersion Then
'If it reads blank, then the internet connection is faulty.
If Read = "" Then
MsgBox("ERROR: Please check your internet connection, check the website, or try later.")
Else
Msgbox("Downloading!")
WebClient2.DownloadFileAsync(New Uri("https://blahblahblah.com/link.txt"), "link.txt")
End If
Else
Msgbox("Program is up to date")
End If
End Sub
[/php]
This will read the download link and it will direct the web-browser to it.
WebClient2_DownloadFileCompleted
[php]
Private Sub WebClient2_DownloadFileCompleted(ByVal sender As System.Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles WebClient2.DownloadFileCompleted
Dim Link As String = My.Computer.FileSystem.ReadAllText("link.txt")
WebBrowser1.Navigate(Link)
End Sub
[/php]
The use of a link.txt is that if you upload different versions, the download link might change so the program will fetch the right one from the text file.
If you want to update, edit your version.txt (1.0.0.0 -> 1.1.0.0) and provide a download link in link.txt. You will need to find somewhere to host the files but you also have to sure that the url never changes. I use webs to host the text files since the url will always be.
Also, you can edit the text with out re-uploading. An alternative is Spam.
NextGen1: User Provided sufficient evidence that the original poster on another site and noob are one in the same.
Last edited by NextGen1; 04-11-2010 at 10:11 AM.
Steve323 (05-27-2010)
Thank You For Sharing.
Also, as of Vb.net 2005 ( I don't remember if 2003 had it or not) Auto Updater source
became "Obsolete". It was replaced with Click Once and the built in function which made
it easy, and there is no need for this extra code.
Last edited by NextGen1; 04-11-2010 at 10:17 AM.
Steve323 (05-27-2010)
Nice job, but there are a lot of tutorials about this..
Steve323 (05-27-2010),technologicpunk (04-10-2010)