URLDownloadToFile API help ***RESOLVED***
I am using the URLDownloadToFile API to download a list of files. The problem I am having is that it is sometimes (like every other file) throwing an error that the filename doesn't exist(duh I am downloading it). What I need is to either be able to handle the error or to stop it from happening. Here is my code:
VB Code:
'declaration
Public 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
'code
Public Function DownloadFile(URL As String, LocalFilename As String, LocalDate As Date) As Boolean
Dim lngRetVal As Long
lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
If lngRetVal = 0 Then DownloadFile = True
Call SetFileDate(LocalFilename, CDate(Month(LocalDate) & "/" & Day(LocalDate) & "/" & Year(LocalDate)), Hour(LocalDate) & ":" & Minute(LocalDate) & ":" & Second(LocalDate))
End Function
'calling function
Call DownloadFile(DLLocation & sFileName, sPath & sFileName, dStamp)
Thanks in advance for any suggestions.