Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleDownload a file from the Web
Keywordsdownload file, get file, Web, Internet
CategoriesInternet, Files and Directories
 
Use the Internet Transfer control's OpenURL method to load the file into an array of bytes. Then open a file for binary access and write the array into the file.
 
Private Sub cmdGo_Click()
Dim bytes() As Byte
Dim fnum As Integer

    cmdGo.Enabled = False
    txtFile.Enabled = False
    txtURL.Enabled = False
    Screen.MousePointer = vbHourglass
    DoEvents

    ' Get the file.
    bytes() = inetDownload.OpenURL( _
        txtURL.Text, icByteArray)

    ' Save the file.
    fnum = FreeFile
    Open txtFile.Text For Binary Access Write As #fnum
    Put #fnum, , bytes()
    Close #fnum

    cmdGo.Enabled = True
    txtFile.Enabled = True
    txtURL.Enabled = True
    Screen.MousePointer = vbDefault
    Beep
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated