Results 1 to 16 of 16

Thread: [RESOLVED] Does DownloadURLToFile download a cache?

  1. #1

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

    Resolved [RESOLVED] Does DownloadURLToFile download a cache?

    Because I want to download the file every time (text file) because it might have changes. It seems that if i change the text file on my FTP, that it will download the same info. However if i add a new file with the same info, it will download the correct info..?

    I know the servers working because when i goto the webpage through IE or FX it works, anyone know if it makes a cache somewhere?

  2. #2
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959

    Re: Does DownloadURLToFile download a cache?

    I use ftp.exe in a script for ftp downloads, might be useful.

    VB Code:
    1. Set filesys = CreateObject("Scripting.FileSystemObject")
    2. Set wshellx = CreateObject("wscript.shell")
    3. Set sfile = filesys.CreateTextFile("c:\file.txt", True)
    4.  
    5. sfile.WriteLine "open yourftp"
    6. sfile.WriteLine "username"
    7. sfile.WriteLine "password"
    8. sfile.WriteLine "cd www"
    9. sfile.WriteLine "binary"
    10. sfile.WriteLine "get " & chr(34) & "yourtextfile.txt" & CHR(34) & chr(32) & chr(34) & "c:\file.txt" & CHR(34)
    11. sfile.WriteLine "disconnect"
    12. sfile.WriteLine "bye"
    13. sfile.Close
    14. For i = 0 To 2000
    15. Next
    16. wshellx.run "ftp  -s:" & "c:\file.txt", 0,true

  3. #3

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

    Re: Does DownloadURLToFile download a cache?

    Anyone else have anything? Thanks Jmacp, but I'm kind of looking for a reason for this to happen. I will use it if no one comes up with a solution/reason for it

  4. #4

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

    Re: Does DownloadURLToFile download a cache?

    Has anyone ever experienced this?

  5. #5
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: Does DownloadURLToFile download a cache?

    Could it possibly be looking at the creat date, then if its equal to a stored date (the create date) it will assume it is the same file hence it won't download it and just get the old one for you?

  6. #6

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

    Re: Does DownloadURLToFile download a cache?

    Right after I download the file I open it and take the contents into a string, then delete the file. So that info has to be stored somewhere..?

  7. #7
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: Does DownloadURLToFile download a cache?

    Probably, try searching in "C:\Documents and Settings\{Login Name}\Local Settings\Temporary Internet Files\content.ie5" (In XP)

  8. #8

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

    Re: Does DownloadURLToFile download a cache?

    Thanks but that doesnt work either..Is there a way instead to download not to a file? Like DownLoadURL (not inet)

  9. #9
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Does DownloadURLToFile download a cache?

    Why don't you want to use an Inet control?

  10. #10
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Does DownloadURLToFile download a cache?

    I'm guessing you are talking about the URLDownloadToFile function. In which case, yes - this function first downloads the file to the IE cache and then copies it from there so subsequent calls to this function will pull the cached version of the file. What you can do is to first call the DeleteUrlCacheEntry function before you call the URLDownloadToFile.
    VB Code:
    1. Private Declare Function DeleteUrlCacheEntry Lib "wininet.dll" ( _
    2.     ByVal lpszUrlName As String _
    3. ) As Long
    Simply call this function and pass it the URL of the remote file. If the file doesn't exist in the cache this function simply returns FALSE, but who cares if that is the case

  11. #11

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

    Re: Does DownloadURLToFile download a cache?

    Quote Originally Posted by penagate
    Why don't you want to use an Inet control?
    I want to lose the dependency..

    Thankyou Joacim! I will test and report back

  12. #12

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

    Re: Does DownloadURLToFile download a cache?

    Errm..

    I just tested it, although its returning the correct value..It seems its still keeping the cache.

    Heres a snippet

    VB Code:
    1. Debug.Print DeleteUrlCacheEntry(ServerPath)
    2.         SaveOpen = URLDownloadToFile(0, ServerPath, App.Path & "\temp.vdf", 0, 0)
    3.     FF = FreeFile: Open App.Path & "\temp.vdf" For Input As #FF
    4.         SaveOpen = Input$(LOF(FF), FF)
    5.     Close #FF
    6.     Kill App.Path & "\temp.vdf"

  13. #13
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Does DownloadURLToFile download a cache?

    Declare this constant:
    VB Code:
    1. Private Const BINDF_GETNEWESTVERSION As Long = &H10
    Now change your call to URLDownloadToFile to:
    VB Code:
    1. Call URLDownloadToFile(0&, ServerPath, App.Path & "\temp.vdf", BINDF_GETNEWESTVERSION, 0&)
    But keep the call to DeleteUrlCacheEntry.

  14. #14

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

    Re: Does DownloadURLToFile download a cache?

    Im going to try that, but I think it was me whos at fault. I think i forgot to reupload the newer version to check the 2nd time..Let me test a few more times

  15. #15

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

    Re: Does DownloadURLToFile download a cache?

    Yeah that was it..I forgot to upload/the upload did not work on my FTP. Just tested 6 times, worked like a charm each and every time.

    Thankyou so much Joacim, this helps me out alot..Also a new API that I have never ever heard of

    *Edit*
    Would it be better to still use your code 2 posts up rather than this
    SaveOpen = URLDownloadToFile(0, ServerPath, App.Path & "\temp.vdf", 0, 0)

    Even if it works?

  16. #16
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: [RESOLVED] Does DownloadURLToFile download a cache?

    Using the BINDF_GETNEWESTVERSION would be better if you don't use the DeleteUrlCache function since if you use it the cache is used if no newer file exist on the remote computer.

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