Update using dropbox problems

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
11 posts Page 1 of 2
Contributors
User avatar
master3395
New Member
New Member
Posts: 14
Joined: Wed May 08, 2013 8:17 pm

Update using dropbox problems
master3395
Hello, sorry that i have to ask again, i just have a question, i'm making a program for my school, and i cant seem to get the program to work using update button using dropbox, is there something wrong with this?

it's placed in the "public" folder.

It says "program is up to date" and when i change to a updated version, it says "there is a new update available
and we will download when you click ok"

and when i click ok, i get an error.

Code: Select all
Imports System.Web
Imports System.IO
Imports System.Net.Mail
Imports System.Net

Public Class main


    Public Sub CheckForUpdates()
        Dim dir As String = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
        Dim file As String = dir & "\version.txt"
        Dim run As String = dir & "\update"
        Dim MyVer As String = My.Application.Info.Version.ToString
        If My.Computer.FileSystem.FileExists(file) Then
            My.Computer.FileSystem.DeleteFile(file)
        End If
        My.Computer.Network.DownloadFile("https://dl.dropboxusercontent.com/u/26814535/The%20Robloxian%20Army%20TRA/Version.txt.txt", file)
        Dim LastVer As String = My.Computer.FileSystem.ReadAllText(file)
        If Not MyVer = LastVer Then
            MsgBox("An update is available. Click okay to download the update, and please be patient while the update is downloaded.")
            If My.Computer.FileSystem.FileExists(run & ".msi") Then
                My.Computer.FileSystem.DeleteFile(run & ".msi")
            End If
            My.Computer.Network.DownloadFile("https://dl.dropboxusercontent.com/u/26814535/The%20Robloxian%20Army%20TRA/The%20Robloxian%20Army%20TRA.application", run & ".msi")
            MsgBox("The installer has been downloaded to your documents, and should start as soon as you press okay. If the installer doesn't start, go to your documents and click update.msi. Please tell the installer to install into your existing The Robloxian Army TRA folder to keep your settings. Click okay to close The Robloxian Army TRA Program.")
            Shell(run & ".msi")
        End If
        If Not GetFirstDayOfMonth(Today) = Today Then
            If MyVer = LastVer Then
                MsgBox("The program  is up to date")
            End If
        End If
    End Sub
User avatar
smashapps
Coding Guru
Coding Guru
Posts: 961
Joined: Tue Apr 05, 2011 8:41 am

Re: Update using dropbox problems
smashapps
Code: Select all
If Not MyVer = LastVer Then
Why are you checking to see if it isn't the same, then it's basically saying if it's lower or higher then say there is an update. You're also working with a string you should be comparing the values as a decimal and test if the Newest version is actually higher then the current version.
My name is Tom | Visit my blog where I post new content every day! Tom's Daily Blog | MineCraft is awesome!
User avatar
master3395
New Member
New Member
Posts: 14
Joined: Wed May 08, 2013 8:17 pm

Re: Update using dropbox problems
master3395
Still not working D:
User avatar
smashapps
Coding Guru
Coding Guru
Posts: 961
Joined: Tue Apr 05, 2011 8:41 am

Re: Update using dropbox problems
smashapps
I kept this simple, I did message you the other day but I completely forgot I am so sorry!

We have a text file online and it's 4 lines. In order of the lines it's the Major number, minor, build and then revision (1.0.0.9 etc.) Well I commented some of the code hopefully it makes sense. If you're confused about something just let me know. All you need to do is that the DownFile("") to the path of your version with the format I mention instead of putting 1.0.0.8 like yours put:
1
0
0
8
and we will then build that together to 1.0.0.8.

Code:
Code: Select all
Imports System.Web
Imports System.IO
Imports System.Net.Mail
Imports System.Net

Public Class Form1

    Public vmaj As Integer = 1
    Public vmin As Integer = 0
    Public vbuil As Integer = 0
    Public vrev As Integer = 7
    Public vcurrent As String = vmaj & "." & vmin & "." & vbuil & "." & vrev 'put the version together 
    'Your online version is 1.0.0.8 so we're pretending our application is 1.0.0.7


    Public lmaj As String
    Public lmin As String
    Public lbuil As String
    Public lrev As String
    Public lcurrent As String = lmaj & "." & lmin & "." & lbuil & "." & lrev

    Public Function ReadLine(lineNumber As Integer, lines As List(Of String)) As String
        Try
            Return lines(lineNumber - 1)
        Catch ex As Exception
        End Try
        Return Nothing
    End Function

    Public Sub CheckForUpdates()
        Dim dir As String = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
        Dim file As String = dir & "\version.txt"
        Dim run As String = dir & "\update"
        Dim MyVer As String = My.Application.Info.Version.ToString
        If My.Computer.FileSystem.FileExists(file) Then
            My.Computer.FileSystem.DeleteFile(file)
        End If
        Try
            'Change this to your version text but make sure major is on line one, minor is on line 2, build is on line 3 and revision is on line 4 :)
            My.Computer.Network.DownloadFile("http://pastebin.com/raw.php?i=5TjH3f06", file)
            'Dim LastVer As String = My.Computer.FileSystem.ReadAllText(file)
            If My.Computer.FileSystem.FileExists(file) Then
                Dim ReadFile As New System.IO.StreamReader(file)
                Dim AllLines As List(Of String) = New List(Of String)
                Do While Not ReadFile.EndOfStream
                    AllLines.Add(ReadFile.ReadLine())
                Loop
                ReadFile.Close()
                lmaj = ReadLine(1, AllLines) 'major
                lmin = ReadLine(2, AllLines) 'minor
                lbuil = ReadLine(3, AllLines) 'build
                lrev = ReadLine(4, AllLines) 'revision 
                lcurrent = lmaj & "." & lmin & "." & lbuil & "." & lrev
            End If
            If vrev < lrev Then
                'Current version's revision is lower than the latest revision 
                MsgBox("Update " & lcurrent & " is available. You currently have version: " & vcurrent & " Click okay to download the update, and please be patient while the update is downloaded.")
                If My.Computer.FileSystem.FileExists(run & ".msi") Then
                    My.Computer.FileSystem.DeleteFile(run & ".msi")
                End If
                My.Computer.Network.DownloadFile("https://dl.dropboxusercontent.com/u/26814535/The%20Robloxian%20Army%20TRA/The%20Robloxian%20Army%20TRA.application", run & ".msi")
                MsgBox("The installer has been downloaded to your documents, and should start as soon as you press okay. If the installer doesn't start, go to your documents and click update.msi. Please tell the installer to install into your existing The Robloxian Army TRA folder to keep your settings. Click okay to close The Robloxian Army TRA Program.")
                Shell(run & ".msi")
            Else
                MsgBox("No higher revision of application was found! Up to date :)")
            End If
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        CheckForUpdates()
    End Sub
End Class
if you need more help I am more than willing to assist via Teamviewer, provide more samples, skype, PM, email etc. I enjoy helping.

Image
My name is Tom | Visit my blog where I post new content every day! Tom's Daily Blog | MineCraft is awesome!
User avatar
Shim
VIP - Donator
VIP - Donator
Posts: 882
Joined: Wed Dec 14, 2011 5:02 am

Re: Update using dropbox problems
Shim
i have used dropbox in one of app by the way i don't use a txt file to see the version and download the update i used the normal link and i have added some codes to check for updates in form_load event like if the link response 404 then do nothing but if the link response is not 404 then a message box will popup saying " A new update for this application available , Do you want to update ?" theres a no and yes button if yes clicked my updater app with the main app binary will open and will download the executable and the main app will be killed from process and the main app will be replaced with the updated version :)

EDIT :

now dropbox uses a hash so be noticed
Find my programs on Softpedia
User avatar
smashapps
Coding Guru
Coding Guru
Posts: 961
Joined: Tue Apr 05, 2011 8:41 am

Re: Update using dropbox problems
smashapps
I had problems using a public file in dropbox so I created a text file on Pastebin and just copied the link from the raw file, so it might be worth doing the same thing though the cord I gave you is your code but modified to actually work.
My name is Tom | Visit my blog where I post new content every day! Tom's Daily Blog | MineCraft is awesome!
User avatar
AnoPem
VIP - Donator
VIP - Donator
Posts: 441
Joined: Sat Jul 24, 2010 10:55 pm

Re: Update using dropbox problems
AnoPem
This is just an example you will have to add current in my settings and put the current version of the program
Code: Select all
Imports System.Net

Im just using versions numbers like "1" and "2" not "1.0.0"

          Dim sversion = web.DownloadString("http://dl.dropbox.com/u/17292177/THW%20Web/CNS/version.dat")
        Dim current = My.Settings.current
        If sversion > My.Settings.current Then
            'Download thing here
            MsgBox("Update is complete.", MsgBoxStyle.Information, "Update")
            My.Settings.current = sversion
            Label1.Text = sversion
        ElseIf sversion < My.Settings.current Then
            MsgBox("Something is wrong ?", MsgBoxStyle.Critical, "Update")
        ElseIf sversion = My.Settings.current Then
            MsgBox("Your up to date")
        End If
https://t.me/pump_upp
User avatar
master3395
New Member
New Member
Posts: 14
Joined: Wed May 08, 2013 8:17 pm

Re: Update using dropbox problems
master3395
It does not seem to work, it says that i got a old version, but when i click upgrade, it says "file not found"
User avatar
smashapps
Coding Guru
Coding Guru
Posts: 961
Joined: Tue Apr 05, 2011 8:41 am

Re: Update using dropbox problems
smashapps
Change the link of the file it downloads to a link that actually has a file for it to download. It was your link and it's a 404 I think. Also if it's trying to open it before it downloads just add If My.Computer.FileSystem.FileExists("") you have a working example there you shouldn't have problems
My name is Tom | Visit my blog where I post new content every day! Tom's Daily Blog | MineCraft is awesome!
User avatar
master3395
New Member
New Member
Posts: 14
Joined: Wed May 08, 2013 8:17 pm

Re: Update using dropbox problems
master3395
The problem is that it's not a program, it's a once click program, not a .exe

Application Files "Type" File folder.
Autorun "Type" Information about installation
Setup "Type Program
The Robloxian Army TRA "Type" ClickOnce-program
The Robloxian Army TRA "Type" HTML - Document

Each line is listed, in my folder, after publish.
I want it to install on the user's computer, and check for updates.
And if it checks for updates, does it uninstall the old version?
11 posts Page 1 of 2
Return to “Coding Help & Support”