Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
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-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated