Hey,

I am using URLDownloadToFile API for downloading files from website to which i updated, but this API is retrieving the older files even after i upload a latest version of the file. I used a fake parameters along with the url but in fail.

szFileName = "C:/somename.zip"
surl ="" & int  Where int will change every time when downloading.

DownloadFileFromNet = URLDownloadToFile(0, sURL, szFileName, 0, 0) = ERROR_SUCCESS

Please also let me know whether this API works in Windows VISTA Operating System.

Please help to solve this problem

Dani AI

Generated

— the symptom you saw (URLDownloadToFile giving an older copy even after an upload) is usually the client or an intermediate cache returning a stored response rather than re-downloading. URLDownloadToFile is part of Urlmon and the download goes through the system Internet stack, which uses WinINet disk caching and honors HTTP cache headers; that explains why a previously cached file can be reused. (learn.microsoft.com)

Adding a changing query string sometimes fails to “bust” the copy because shared caches or CDNs can be configured to ignore query parameters or to obey origin cache rules instead of the client’s query trick. The most reliable fixes are server-side (proper Cache‑Control / ETag headers) or publishing a new versioned filename. (developers.cloudflare.com)

Practical options (ordered by simplicity and reliability):

  • Clear the URL cache entry before the download (this is what ’s advice effectively did and why it worked). (learn.microsoft.com)
  • If you must stay on Urlmon/URLDownloadToFile, implement an IBindStatusCallback and set bind flags (e.g., request the newest version and avoid writing to cache) so the moniker forces a reload. (learn.microsoft.com)
  • Or switch to a controllable HTTP client (WinHTTP / WinHttpRequest or MSXML2.XMLHTTP), set request headers like Cache-Control: no-cache, then write the binary response to disk (ADODB.Stream). Example VB pattern:
Dim http As Object
Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
http.Open "GET", sURL, False
http.SetRequestHeader "Cache-Control", "no-cache"
http.Send

If http.Status = 200 Then
  Dim stm As Object
  Set stm = CreateObject("ADODB.Stream")
  stm.Type = 1
  stm.Open
  stm.Write http.ResponseBody
  stm.SaveToFile szFileName, 2
  stm.Close
End If

(WinHttpRequest and ADODB.Stream are appropriate for service/automation scenarios.) (learn.microsoft.com)

URLDownloadToFile is available on Vista (it’s a Urlmon API), but beware: when run as a service or under a different account the cache lives in the system profile and behavior can differ — that’s another reason to prefer WinHTTP for services. (learn.microsoft.com)

Hope this clarifies why the cache served the old ZIP and gives practical alternatives you can apply.

Recommended Answers

All 3 Replies

Thanks it is downloading the latest file after deleting the cache. Thanks a lot.

you can use msinet control with have many sample
Micrsoft Internet Transfer Control 6.0 (SP6)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.