Results 1 to 3 of 3

Thread: Whats the best/easiest way to (synchronously) download a file from the internet?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2003
    Posts
    1,269

    Whats the best/easiest way to (synchronously) download a file from the internet?

    Without ever getting a cached copy?

  2. #2
    Hyperactive Member
    Join Date
    Jun 2006
    Posts
    372

    Re: Whats the best/easiest way to (synchronously) download a file from the internet?

    use the URLDOWNLOADTOFILE API, and append a cahce-busting string to the end of the url:

    where:
    http://www.vbforums.com/showthread.php?t=458435

    becomes:
    http://www.vbforums.com/showthread.p...58435&jnk=3535

    either use rnd to generate a random string, or use
    timer*100

    i believe there might be a way to prevent caches with an argument to the API call, but i don't know what it is.
    vb Code:
    1. Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, _
    2.     ByVal dwReserved As Long, _
    3.     ByVal lpfnCB As Long) As Long
    4.  
    5.  
    6. Public Function Url2File(URL As String, _
    7.     LocalFilename As String) As Boolean
    8.     Dim lngRetVal As Long
    9.     lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
    10.    
    11.     If lngRetVal = 0 Then Url2File = True
    12. End Function

  3. #3
    Hyperactive Member Hassan Basri's Avatar
    Join Date
    Sep 2006
    Posts
    324

    Re: Whats the best/easiest way to (synchronously) download a file from the internet?

    Here is another manner using URLDownloadToFile and DeleteUrlCacheEntry:

    http://vbnet.mvps.org/index.html?cod...ilenocache.htm

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