Results 1 to 4 of 4

Thread: URLDownloadToFile API help ***RESOLVED***

  1. #1

    Thread Starter
    Frenzied Member seoptimizer2001's Avatar
    Join Date
    Apr 2001
    Location
    Toledo, Ohio USA GMT -5
    Posts
    1,075

    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:
    1. 'declaration
    2. Public Declare Function URLDownloadToFile Lib "urlmon" Alias _
    3.     "URLDownloadToFileA" (ByVal pCaller As Long, _
    4.     ByVal szURL As String, _
    5.     ByVal szFileName As String, _
    6.     ByVal dwReserved As Long, _
    7.     ByVal lpfnCB As Long) As Long
    8.  
    9. 'code
    10. Public Function DownloadFile(URL As String, LocalFilename As String, LocalDate As Date) As Boolean
    11.     Dim lngRetVal As Long
    12.    
    13.     lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
    14.     If lngRetVal = 0 Then DownloadFile = True
    15.    
    16.      Call SetFileDate(LocalFilename, CDate(Month(LocalDate) & "/" & Day(LocalDate) & "/" & Year(LocalDate)), Hour(LocalDate) & ":" & Minute(LocalDate) & ":" & Second(LocalDate))
    17. End Function
    18.  
    19. 'calling function
    20.  Call DownloadFile(DLLocation & sFileName, sPath & sFileName, dStamp)
    Thanks in advance for any suggestions.
    Last edited by seoptimizer2001; Nov 11th, 2002 at 11:14 AM.
    seoptimizer2001
    VB 6.0, VC++, VI, ASP, JavaScript, HTML,
    Perl, XML, SQL Server 2000

    If God had intended us to drink beer, He would have given us stomachs.


    Please use the [code] and [vbcode] tags in your posts!
    If you don't know how to use them please go HERE!


  2. #2

    Thread Starter
    Frenzied Member seoptimizer2001's Avatar
    Join Date
    Apr 2001
    Location
    Toledo, Ohio USA GMT -5
    Posts
    1,075
    Sorry but ............. bump
    seoptimizer2001
    VB 6.0, VC++, VI, ASP, JavaScript, HTML,
    Perl, XML, SQL Server 2000

    If God had intended us to drink beer, He would have given us stomachs.


    Please use the [code] and [vbcode] tags in your posts!
    If you don't know how to use them please go HERE!


  3. #3
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    It would seem that the error is caused by the SetFileDate()
    when a file fails to download.

    To prevent the error, simply insert the code which sets the date
    into the If statement which is currently setting your return
    value to True.

  4. #4

    Thread Starter
    Frenzied Member seoptimizer2001's Avatar
    Join Date
    Apr 2001
    Location
    Toledo, Ohio USA GMT -5
    Posts
    1,075
    Yep that was it. Thanks, it is still a little early on a Monday for me and I didn't even think of that!
    seoptimizer2001
    VB 6.0, VC++, VI, ASP, JavaScript, HTML,
    Perl, XML, SQL Server 2000

    If God had intended us to drink beer, He would have given us stomachs.


    Please use the [code] and [vbcode] tags in your posts!
    If you don't know how to use them please go HERE!


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width