|
-
Jan 7th, 2006, 02:24 PM
#1
Thread Starter
Admodistrator
[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?
-
Jan 7th, 2006, 02:41 PM
#2
Re: Does DownloadURLToFile download a cache?
I use ftp.exe in a script for ftp downloads, might be useful.
VB Code:
Set filesys = CreateObject("Scripting.FileSystemObject")
Set wshellx = CreateObject("wscript.shell")
Set sfile = filesys.CreateTextFile("c:\file.txt", True)
sfile.WriteLine "open yourftp"
sfile.WriteLine "username"
sfile.WriteLine "password"
sfile.WriteLine "cd www"
sfile.WriteLine "binary"
sfile.WriteLine "get " & chr(34) & "yourtextfile.txt" & CHR(34) & chr(32) & chr(34) & "c:\file.txt" & CHR(34)
sfile.WriteLine "disconnect"
sfile.WriteLine "bye"
sfile.Close
For i = 0 To 2000
Next
wshellx.run "ftp -s:" & "c:\file.txt", 0,true
-
Jan 7th, 2006, 05:44 PM
#3
Thread Starter
Admodistrator
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
-
Jan 7th, 2006, 08:25 PM
#4
Thread Starter
Admodistrator
Re: Does DownloadURLToFile download a cache?
Has anyone ever experienced this?
-
Jan 7th, 2006, 08:35 PM
#5
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?
-
Jan 7th, 2006, 08:44 PM
#6
Thread Starter
Admodistrator
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..?
-
Jan 7th, 2006, 08:55 PM
#7
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)
-
Jan 8th, 2006, 12:16 AM
#8
Thread Starter
Admodistrator
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)
-
Jan 8th, 2006, 05:18 AM
#9
Re: Does DownloadURLToFile download a cache?
Why don't you want to use an Inet control?
-
Jan 8th, 2006, 06:40 AM
#10
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:
Private Declare Function DeleteUrlCacheEntry Lib "wininet.dll" ( _
ByVal lpszUrlName As String _
) 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
-
Jan 8th, 2006, 01:07 PM
#11
Thread Starter
Admodistrator
Re: Does DownloadURLToFile download a cache?
 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 
-
Jan 8th, 2006, 01:17 PM
#12
Thread Starter
Admodistrator
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:
Debug.Print DeleteUrlCacheEntry(ServerPath)
SaveOpen = URLDownloadToFile(0, ServerPath, App.Path & "\temp.vdf", 0, 0)
FF = FreeFile: Open App.Path & "\temp.vdf" For Input As #FF
SaveOpen = Input$(LOF(FF), FF)
Close #FF
Kill App.Path & "\temp.vdf"
-
Jan 8th, 2006, 01:48 PM
#13
Re: Does DownloadURLToFile download a cache?
Declare this constant:
VB Code:
Private Const BINDF_GETNEWESTVERSION As Long = &H10
Now change your call to URLDownloadToFile to:
VB Code:
Call URLDownloadToFile(0&, ServerPath, App.Path & "\temp.vdf", BINDF_GETNEWESTVERSION, 0&)
But keep the call to DeleteUrlCacheEntry.
-
Jan 8th, 2006, 01:58 PM
#14
Thread Starter
Admodistrator
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
-
Jan 8th, 2006, 02:01 PM
#15
Thread Starter
Admodistrator
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?
-
Jan 8th, 2006, 02:36 PM
#16
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|