|
|
Title | Download a file from the Web |
Keywords | download file, get file, Web, Internet |
Categories | Internet, 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
|
|
|
|
|
|