Results 1 to 5 of 5

Thread: Downloading with Inet

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2000
    Location
    Manchester, UK
    Posts
    50

    Question

    Could someone tell me how to download a file via HTTP and also display how much of the file has been downloaded?

  2. #2
    Guest
    Downloading:
    Code:
    Using Microsoft Internet Explorer:
    
    Private Declare Function DoFileDownload Lib "shdocvw.dll" (ByVal lpszFile As
    String) As Long
    
    
    Private Sub Command1_Click()
    
       Dim sDownload As String
    
       sDownload = StrConv(file, vbUnicode)
       Call DoFileDownload(sDownload)
    
    End Sub
    
    Using Inet:
    
    Private Sub Command1_Click()
        Dim iFile As Integer
        Dim bBIN() As Byte
        
        Caption = "Downloading.."
        bBIN = Inet1.OpenURL("www.vb-world.net/images/vbworld.gif", icByteArray)
        iFile = FreeFile
        Open "C:\vbworld.gif" For Binary Access Write As iFile
            Put #iFile, , bBIN
        Close iFile
        Caption = "Download Complete."
    End Sub
    Hope that helps.

  3. #3
    Addicted Member
    Join Date
    May 2000
    Posts
    142
    there is a bug in openURL method.

    see one of my previsou thread on this topic for the KB article with solution.

    /d8
    Secret to long life:
    Keep breathing as long as possible.

  4. #4
    Guest
    Try using Winsock.

    Code:
    'Public declarations
    Dim FileOpen as Boolean
    
    
    Public Function Send_File(FileToSend as string)
        'This is the function that sends a file
        Dim Temp as String
        Dim BlockSize as Long
        open filetosend For binary access read as #1 'Open the file to send
        BlockSize = 2048 'Set the block size, If needed, set it higher
    
    
        Do While not EOF(1)
            temp = Space$(blockSize) 'Give temp some space to store the data
            Get 1, , temp 'Get first line from file
            Winsock1.SendData temp 'Send the data
    
    
            DoEvents
            loop
            winsock1.senddata "xx" 'This is a custom control that ends the transmition
            close #1
        End Function
    
    
    Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
        Dim temp As String
        Dim data As String
        'Check to see if the file is already ope
        '     n
    
    
        If fileOpen = False Then
            Open "c:\somefile_here" For Binary Access Write As #2
            fileOpen = True
        ElseIf fileOpen = True Then
    
    
            DoEvents
            End If
            Winsock1.GetData data 'Get the data
            temp = data
            'Check to see if it is the end of the tr
            '     ansmition
    
    
            If temp = "xx" Then
                Close #2
                fileOpen = False
            Else
                Put 2, , temp 'Store the data to the file
            End If
        End Sub

  5. #5

    Thread Starter
    Member
    Join Date
    Jun 2000
    Location
    Manchester, UK
    Posts
    50

    Angry Thanks, but not quite what I want

    Thanks for all that, but what I actually want is to use the Inet control to download via HTTP and show how much of the file is downloaded, e.g (Downloaded 4.7K of 501K at 4.4K/Sec)


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width