|
-
Mar 17th, 2011, 03:22 PM
#1
Thread Starter
Junior Member
How to make an updater?
Ok, So I am trying to make an updater for one of my applications but i need to know how to figure out if the updated file exists. I have this but it doesnt work... i was wondering if anyone could tell me how to do this. I would be very greatful. Thankyou...
Current Code:
Code:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If My.Computer.FileSystem.FileExists("http://www.domain.com/file.exe") Then
My.Computer.Network.DownloadFile("http://www.domain.com/file.exe", "C:/file.exe")
MsgBox("YES")
Else
MsgBox("NO!")
End If
End Sub
End Class
Thank you for ANY help.
-
Mar 17th, 2011, 03:56 PM
#2
Thread Starter
Junior Member
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.
-
Mar 17th, 2011, 04:17 PM
#3
Thread Starter
Junior Member
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.
-
Mar 17th, 2011, 05:24 PM
#4
Addicted Member
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....
-
Mar 17th, 2011, 06:04 PM
#5
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.
-
Mar 19th, 2011, 01:12 PM
#6
Thread Starter
Junior Member
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.
-
Mar 19th, 2011, 01:20 PM
#7
Re: How to make an updater?
You've got a weird host...
-
Apr 14th, 2011, 04:22 PM
#8
Thread Starter
Junior Member
Re: How to make an updater?
haha yes i do, but its free so I'm not complaining.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|