Re: How to make an updater?
I think i found a way to do this...
i just would have to have a separate file on the website with the version in it.
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
My.Computer.Network.DownloadFile("http://host.com/version.txt", My.Computer.FileSystem.SpecialDirectories.Temp & "\version.txt")
Dim a As New System.IO.StreamReader(My.Computer.FileSystem.SpecialDirectories.Temp & "\version.txt")
Dim b As String = a.ReadToEnd
a.Close()
If Not b = "V2" Then
MsgBox("NO UPDATE!")
Else
If MsgBox("Update Found. Would you like to update now?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
My.Computer.Network.DownloadFile("http://host.com/file.exe", My.Computer.FileSystem.SpecialDirectories.Temp & "\file.exe")
MsgBox("Updated!")
End If
End If
End Sub
I still need to test this but unfortunatly i am not near my computer that i can do that on. I will let you know if it works.
Re: How to make an updater?
I was able to go home and test it and i got it to work with this code...
This will update an Application of mine when it finds that there IS an update it will navigate to the page on my site where you can download it. And for some strang reason my site wouldnt let me use text files so i had to store the text in a JPG. But you should be able to use Text files... it is still wierd though... Anyhoo.... here is the working code for anyone who cares.
Code:
Private Sub CheckForUpdatesNowToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckForUpdatesNowToolStripMenuItem.Click
If My.Computer.FileSystem.FileExists(My.Computer.FileSystem.SpecialDirectories.Temp & "\version.jpg") Then
My.Computer.FileSystem.DeleteFile(My.Computer.FileSystem.SpecialDirectories.Temp & "\version.jpg")
End If
My.Computer.Network.DownloadFile("http://thefiscster510.hostzi.com/data/apps/phpdata/version.jpg", My.Computer.FileSystem.SpecialDirectories.Temp & "\version.jpg")
Dim a As New System.IO.StreamReader(My.Computer.FileSystem.SpecialDirectories.Temp & "\version.jpg")
Dim b As String = a.ReadToEnd
a.Close()
If Not b = "V2" Then
MsgBox("You are currently Up-To-Date.")
Else
If MsgBox("Update Found. Would you like to update now?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
Process.Start("http://thefiscster510.hostzi.com/data/download.php?D_FILE1=Guest&D_FILE2=wamp.zip")
End If
End If
My.Computer.FileSystem.DeleteFile(My.Computer.FileSystem.SpecialDirectories.Temp & "\version.jpg")
End Sub
Hope this somehow helped.
Re: How to make an updater?
I've completed this task using this logic.
Get current assembly.exe version number.
Check website xml file for current version number
If needed download the new version
Save the file as assemblyname.updater.exe
Launch the assemblyname.updater.exe file and exit the assemblyname.exe
On assembly start up check to see if the assembly is "assemblyname.updater.exe"
If it is delete assemblyname.exe, and copy the updater file to assemblyname.exe
Start assemblyname.exe and delete assemblyname.updater.exe if it exists.
I know there has got to be an easier way....
Re: How to make an updater?
This is how I do it:
1) Download text-file from sever which contains a number (e.g. 1.0.0.1)
2) Compare the number with assembly-number
3) If number of server-file higher then Close mainApp and start Update.exe (the update.exe is in the app.path)
4) Update.exe >> Download new .exe and replace the old one.
5) Start the new .exe (mainApp) and close updater.
Re: How to make an updater?
That is what i did... i just had to use a JPEG cause my host doesnt like txt files.
Re: How to make an updater?
You've got a weird host...
Re: How to make an updater?
haha yes i do, but its free so I'm not complaining.