CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2014
    Posts
    5

    URLDownloadToFile failed with 800c0008 (Download failure)

    Hi there, I'm new here and hope I get here a solution for my problem.
    First of all, this function worked already for a long time. So, I assume something in my environment changed and thats the reason for the failure, but I don't have any clue anymore, what it could be.
    I wrote a program, which includes the download of an xml file from the european central bank containing the currency exchange rates to update the prices.
    Its quite simple as you can see

    rtn = URLDownloadToFile(lCaller, url, sFile, 0, 0)

    sFile is just a temporary file name which is beeing deleted before (in case it exist)
    url is url=http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml (you can try it in the browser. The url exist. I even tried it with another file at my own webspace, but same result)

    I always get the error code mentioned in the title above
    I googled a while and read several things about deleting the cache before, but even I call

    rtn = DeleteUrlCacheEntry(url)

    before, the result is the same. I event tried to disable the firewall (a solution I read somewhere too), same result. The bad thing is, I don't know since when it stopped working. I reinstalled the PC a while ago as I've had problems with my harddisk (installed a new HD). But I use the same OS as before (Win7 64bit). And (as mentioned) I don't know when it stopped working. Fortunately the PCs of my customer are not affected.

    Anybody any idea, what I can try?

    Thanks in advance and greetings from Germany

  2. #2
    Join Date
    Jun 2014
    Posts
    5

    Re: URLDownloadToFile failed with 800c0008 (Download failure)

    Nobody an idea?
    Maybe some of you can try the following and report if successful or not and which Windows-Version with which Internet-Explorer Version. I googled a while and it seems to me, it could be that the IE-Version has some

    declaration:
    Declare Function URLDownloadToFile Lib "urlmon.dll" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal Reserved As Long, ByVal fnCB As Long) As Long

    Private Sub testURLDownloadToFile()

    Dim lCaller As Long
    Dim sFile As String
    Const sUrl As String = "http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml"

    sFile = Environ("TEMP")
    If Right$(sFile, 1) <> "\" Then sFile = sFile & "\"
    sFile = sFile & "test.xml"
    If Dir(sFile) <> "" Then Kill sFile

    MsgBox Hex(URLDownloadToFile(lCaller, sUrl, sFile, 0, 0))

    End Sub

    Here at my company laptop with Win7 Professional 64bit and IE 8 it returns 0, so it works.

  3. #3
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: URLDownloadToFile failed with 800c0008 (Download failure)

    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  4. #4
    Join Date
    Jun 2014
    Posts
    5

    Re: URLDownloadToFile failed with 800c0008 (Download failure)

    Hi,

    as I did not find anything about this problem, I changed the code and use now the "Microsoft Internet Transfer Control".

    Set HTTP = Inet1
    With HTTP
    .Protocol = icHTTP
    .url = url
    Contents() = .OpenURL(.url, icByteArray)
    End With
    Set HTTP = Nothing

    If Dir(sFile) <> "" Then Kill sFile
    Open sFile For Binary Access Write As #1
    Put #1, , Contents()
    Close #1

    This works.

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

Featured