Results 1 to 4 of 4

Thread: URLDownloadToFile not working.

  1. #1

    Thread Starter
    Fanatic Member Nove's Avatar
    Join Date
    Jul 2004
    Posts
    736

    URLDownloadToFile not working.

    Here's my code.

    VB Code:
    1. Private Sub cmdUpdate_Click()
    2.     Dim GoodOrBad As Long
    3.     Dim URL As String
    4.     Dim EndPath As String
    5.     URL = UpdateLink & "data.ssl"
    6.     EndPath = App.Path & "data2.ssl"
    7.     lblVersion.Caption = "Downloading File..."
    8.     GoodOrBad = URLDownloadToFile(0, URL, EndPath, 0, 0)
    9.     If GoodOrBad = 0 Then
    10.         lblVersion.Caption = "Finished."
    11.         MsgBox "File Downloaded."
    12.         frmSpellSwap.LoadData
    13.     Else
    14.         MsgBox "There was a problem downloading the file."
    15.         lblVersion.Caption = "Version: " & Version
    16.     End If
    17. End Sub

    When I run this, the file doesn't actually download and GoodOrBad always equals zero. What am I doing wrong?

  2. #2
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: URLDownloadToFile not working.

    VB Code:
    1. hey = URLDownloadToFile(0, ServerPath, App.Path & "\temp.vdf", 0, 0)

    Is the format..

    It should return 0 always, that measn it downloaded the file..You then need to open the file using the App.Path & "\temp.vdf" parameter.

    Also, youre file wont download everytime, only the first. You need this reference:

    VB Code:
    1. Public Declare Function DeleteUrlCacheEntry Lib "wininet.dll" ( _
    2.     ByVal lpszUrlName As String _
    3. ) As Long

    And call it before downloading.

  3. #3

    Thread Starter
    Fanatic Member Nove's Avatar
    Join Date
    Jul 2004
    Posts
    736

    Re: URLDownloadToFile not working.

    Thank you very much. I had no idea there was a cache.

  4. #4
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: URLDownloadToFile not working.

    Neither did I until last week, thank Joacim

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