Client Login Area
LiveZilla Live Chat Software
Main Menu
Results 1 to 6 of 6

Thread: Vb.net help.

  1. #1
    Verified Community Member
    Join Date
    March 8, 2010
    Location
    Lakewood, CO
    Posts
    700

    Default Vb.net help.

    I'm working on an updater for my a game im creating in RPG Maker XP. The following is my check for updates button.

    Code:
    Dim MyClient As New WebClient()
    
            Dim time As String = DateTime.Now.ToString("[HH:MM:ss]")
            lbxStatus.Items.Add(time & " Checking for updates.")
    
            AddHandler MyClient.DownloadProgressChanged, AddressOf DownloadProgressChanged
            AddHandler MyClient.DownloadFileCompleted, AddressOf DownloadFileCompleted2
            'put the location of your ver.txt
            Dim uri As New Uri("http://thelegend.crzyproductions.com/ver.txt")
            MyClient.DownloadFileAsync(uri, "\Patch\ver.txt")
    For some reason its not over writing the ver.txt I have in the patch foloder. Or even downloading it for that matter. Am i missing something here? Here is Download file completed2

    Code:
    Private Sub DownloadFileCompleted2(ByVal sender As Object, ByVal e As AsyncCompletedEventArgs)
            Dim latest As String = File.ReadAllText("Patch\ver.txt")
            Dim current As String = File.ReadAllText("ver.txt")
            Dim time As String = DateTime.Now.ToString("[HH:MM:ss]")
    
            If latest = current Then
                lbxStatus.Items.Add(time & " Your up-to-date")
            Else
                lbxStatus.Items.Add(time & " Update Available")
                btnPlay.Enabled = False
    
                btnCheck.Enabled = False
                btnUpdate.Enabled = True
    
                btnInstall.Visible = True
            End If
    
            lbxStatus.Visible = True
    
            lblDownloading.Visible = False
            pbrDownload.Visible = False
            lblProgress.Visible = False
        End Sub
    Also is it possible to copy the ver.txt once its downloaded and the update is complete to a different folder? but keep the one in the patch folder?

    Thought it should go into programming since it is programming.

  2. #2
    Asif
    Guest

    Default

    First off, You are downloading the complete file taking into a string and taking the other(previous) file in the string, comparing both and telling if there are any changes, better it would be if you would make a system to check only the time stamp. For example a web service method to tell that latest version is 1.0.0.6 and the version on local is 1.0.0.2 so there is an update, how was that using Web Service etc?

    Second is that since you are comparing the file on completed event what are you doing at progress changed event really? For me if you download file Async or not it doesn't really make a difference so why not try a sync call rather than async and try simple DownloadFile method(not async)?

    Let me know what are the results.

    Thanks

  3. #3
    Verified Community Member
    Join Date
    March 8, 2010
    Location
    Lakewood, CO
    Posts
    700

    Default

    So let me get this together so I understand what you are saying. I should use downloadFile instead of Async and then compare. I should of said this converted form a c# project that is open source. So I don't know anything about download. I've been learning sql. So if you have an example that would be very helpful. If not I'll continue to google things.

  4. #4
    Asif
    Guest

    Default

    C# code
    ----------
    //get the create the url
    WebClient client = new WebClient();
    string trashFile = string.Format(@"{0}\{1}.{2}", uploadPath, fileName, request.FileExtension);
    DirectoryInfo trashDir = new DirectoryInfo(uploadPath);
    trashDir.CreateIfNotExists();
    try
    {
    client.DownloadFile(downloadPath, trashFile);
    status = QueueStatus.Unknown;
    }
    catch
    {
    status = QueueStatus.ProcessFailedTooManyErrors;
    return null;
    }


    VB.NET code
    ----------------


    1. 'get the create the url
    2. Dim client As New WebClient()
    3. Dim trashFile As String = String.Format("{0}\{1}.{2}", uploadPath, fileName, request.FileExtension)
    4. Dim trashDir As New DirectoryInfo(uploadPath)
    5. trashDir.CreateIfNotExists()
    6. Try
    7. client.DownloadFile(downloadPath, trashFile)
    8. status = QueueStatus.Unknown
    9. Catch
    10. status = QueueStatus.ProcessFailedTooManyErrors
    11. Return Nothing
    12. End Try

  5. #5
    Verified Community Member
    Join Date
    March 8, 2010
    Location
    Lakewood, CO
    Posts
    700

    Default

    Thanks for your help. It really did help. Its all working except the game launching. I realized I didn't add any code for that. lol

  6. #6
    ASPnix Administration Roma's Avatar
    Join Date
    June 27, 2005
    Location
    Denver, CO
    Posts
    4,066

    Default

    I'm glad our Senior Developer was able to help you. Kudos to him, he is leading the team that works on our new control panel. But please no questions to him about this. It's a secret for now.
    Roma
    Friendly ASPnix Administrator


    https://www.aspnix.com
    roma@aspnix.com



    ASPnix on Facebook

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
  •