FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


VB.NET Dowloader





fromegame
Hi, I've made an updater for my program.
This is what is does.

1. Checks the current version and newest version. (if needed to update..)
2. If update is needed, then check what files has to be updated.
3. Download files to be updated.
4. Overwrite those files.

Problems:

1. It only downloads 1 file, I use a 'for' loop to loop through each filename and download it, but when the first file is downloaded, it stops downloading the next files.

Code:

Code:
    Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
        Dim InstallPath As String = "C:\MyProgram\"
        VersionNumber = GetPageHTML("www.domain.com/NVersion.dat")
        If (My.Settings.VersionNumber = VersionNumber) Then
            MsgBox("Program up to date")
        Else
            Dim FilesToEditPage As String = GetPageHTML("http://www.domain.com/Updates/" & VersionNumber & "/" & "getfiles.dat")
            Dim FilesToEdit() As String = Split(FilesToEditPage, "|||||")
            Dim TotalFilesToEdit As Integer = FilesToEdit.Length
            Dim i As Integer
            For i = 0 To TotalFilesToEdit - 1
                startSize = 0
                Dim Request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("http://www.domain.com/Updates/" & VersionNumber & "/" & FilesToEdit(i))
                Dim Response As System.Net.HttpWebResponse
                Response = Request.GetResponse()
                Dim H As String = Response.GetResponseHeader("Content-Length")
                Dim args() As Object = {FilesToEdit(i), H, VersionNumber}
                SaveFile = InstallPath & "Updates\" & VersionNumber & "\" & FilesToEdit(i)
                TotalSize = H
                TotalFiles = TotalFilesToEdit
                FileNow = i
                thread2.RunWorkerAsync(args)
                While (thread2.IsBusy = True)
                    Application.DoEvents()
                End While
            Next i
        End If
    End Sub

    Private Sub thread2_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles thread2.DoWork
        Dim InstallPath As String = "C:\MyProgram\"
        If (My.Computer.FileSystem.FileExists(InstallPath & "Updates\" & e.Argument(2) & "\" & e.Argument(0)) = True) Then
            My.Computer.FileSystem.DeleteFile(InstallPath & "Updates\" & e.Argument(2) & "\" & e.Argument(0))
        End If
        Dim i As Integer
        Dim dlg As New SetTimer(AddressOf SetTimerF)
        Dim args() As Object = {True}
        Me.Invoke(dlg, args)
        My.Computer.Network.DownloadFile("http://www.domain.com/Updates/" & e.Argument(2) & "/" & e.Argument(0), InstallPath & "Updates\" & e.Argument(2) & "\" & e.Argument(0))
    End Sub

    Private Sub tmrRefresh_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrRefresh.Tick
        Dim FileSz As Long = FileLen(SaveFile)
        If (FileSz = TotalSize And FileNow = TotalFiles - 1) Then
            tmrRefresh.Enabled = False
            Dim Type As Integer
            MsgBox("All Downloads Ready")
        End If
    End Sub


What now Sad
Related topics
What computer languages you know?
visual basic.net
VB.NET school
VB 6 and vb.net tutorials
VB.NET and SQL Server
VB.NET learning
Need vb.net or Flash ActionScript Help!
VB.Net Or C#
A confusion with C# and VB.NET...
[VB.NET] Open a page using IE cookies
OMG! vb.net without connection to server option?
What is your recommended free VB.net decompiler?
vb.net class as property of another class - FIXED
VB.net WPF usercontrols, parent objects and the...[RESOLVED]
Reply to topic    Frihost Forum Index -> Scripting -> Others

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.