Downloading a file from the internet to the local machine

R4PM0NK3Y

Newcomer
Joined
Dec 1, 2003
Messages
14
I want to download a file from the internet to a directory somewhere on the local machine. The code I have tried before is this:

Visual Basic:
 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
    Public Function DownloadFile(ByVal URL As String, ByVal LocalFilename As String) As Boolean
        Dim lngRetVal As Long
        lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
        If lngRetVal = 0 Then DownloadFile = True
    End Function

'Example
DownloadFile("http://www.dotnetforums.com", "C:\DotNetForums\dotnetforums.html")

This code produces NO build errors and NO runtime errors, however the file is NOT written to the directory. Could someone help me with this? Thanks. :)
 
Back
Top