So you want your program to auto update. Well, here's the easy way I coded
First, make a new project. I suggest making a project first to test it out THEN adding it in to your program.
Now, add a WebBrowser. Make it Visible = false.
Next, add 2 Web Clients. To get a Web Client, first right click on one of your controls/blank space in the GENERAL SECTION(very important!) in the Toolbox and click Choose Items.
https://j.image*********/0811/chooseitems.png < view me!
Then, scroll down to the bottom. Scroll up a TINY bit from there and you will see a checkbox marked WebClient.
[img]https://h.image*********/0453/webclient.png[/img]
Check it and click OK.
You should see something like this:
[img]https://h.image*********/0289/webclientinsection.png[/img]
Now click on that and drag in to your form 2 (2!) times. DO NOT RENAME THEM!
Now add two labels.
Arrange the labels like this:
Status: Checking for updates...
and put them anywhere on your form. I prefer the bottom but you can put them anywhere.
Now, add a button. This button can be anywhere and should say "Download Updates" noquotes. Make Enabled=False.
Now for the tricky part.
Double click your form. You should be in the Coding window. You should also be in Form1_Load.
Copy&paste this in: (exactly!)
Code:
WebClient1.DownloadFileAsync(New Uri("https://www.yourftpsite.com/version.txt"), "C:\version.txt")
What this will do is when you open the program it will download a small text file that has the version of your program. (ex. 1.0.0.0)
You must get a FTP server - online or offline - to use this correctly. I will use 110mb.com for this tutorial, it's easy to make an account and go into the FTP.
When you have created your account, go into the FTP. It should look like this on 110mb.
[img]https://j.image*********/0050/ftp.png[/img]
Click the small blue arrow. You should be in a site called "110MBPANEL". You've just gotten into the FTP server, good job.
Now click "New File". You will be presented with a textbox. Type in "version.txt" noquotes and press OK. You will be taken to a large text entry box. However, just type in "1.0.0.0" noquotes for the moment. We will change this later. Now click Save at the bottom and then Back at the bottom.
Go into the coding window of your project again. Add this code underneath Form1_Load.
Code:
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("C:\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 or try later.", MsgBoxStyle.Critical, "ERROR")
Else
Label2.Text = "Update ready to download!"
Button1.Enabled = True
Label2.ForeColor = Color.Green
End If
Else
Button1.Enabled = False
Button1.Text = "Up to date."
Label2.Text = "Up to date."
Label2.ForeColor = Color.Green
End If
End Sub
Add underneath that:
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MsgBox("Downloading new update!")
WebClient2.DownloadFileAsync(New Uri("https://www.yourftpsite.com/link.txt"), "C:\link.txt")
End Sub
Go back into the FTP site again and create a new file, "link.txt" noquotes. Add inside it the DIRECT link to the new updated program. (ex. "www.blahblahblah.com/UpdatedProgram.zip")
THIS PROGRAM HAS TO BE IN A ZIP FILE!!! HAS TO BE!!!! SO PUT IT IN A ZIP FILE!!!!
Ok, now add that ZIP file wherever you put the link to. Try and add it in your FTP server on 110MB.
If it is not in a zip file the webclient will NOT download it. So put it in.
Now add beneath that code in the Coding Window:
Code:
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("C:\link.txt")
MsgBox("Please unzip the application and place in an easily accessible place.")
WebBrowser1.Navigate(Link)
Button1.Enabled = False
Button1.Text = "Update already downloaded."
Label2.Text = "Update already downloaded."
Label2.ForeColor = Color.Red
End Sub
You're done!
All that you need to do whenever you get an update is modify LINK.txt to the new update.ZIP!!!!!!!!! and modify version.txt to your new version. Also, go into your project properties and change the version whenever you update.
You're welcome, if anyone needs ANY help with this just post here and it will be fixed by me or someone else. THANKS FOR VIEWING!
PRESS THANKS!