PDA

Click to See Complete Forum and Search --> : Download from net


007shahid
Feb 16th, 2001, 07:46 AM
How do I download files from the net using VB

kurtsimons
Feb 16th, 2001, 02:19 PM
use the winsock control for or the Inet control

Feb 16th, 2001, 02:58 PM
Or you could use the URLDownloadToFile API function.


Private Declare Function URLDownloadToFile Lib "urlmon" Alias _
"URLDownloadToFileA" (ByVal pCaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long

Private Function DownloadFile(URL As String, _
LocalFilename As String) As Boolean

Dim lngRetVal As Long

lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)

If lngRetVal = 0 Then DownloadFile = True

End Function


Usage


DownloadFile "http://www.site.com/file.txt", "c:\site.txt"

'to return if download was successful:

'Dim Dl As Boolean
'Dl = DownloadFile ("http://www.site.com/file.txt", "c:\site.txt")
'If Dl = True Then
' Msgbox "Download successful"
'Else
' Msgbox "Download failed"
'End If