Re: Weird download problem
Use the BINDF_GETNEWESTVERSION flag.
vb Code:
Private Const BINDF_GETNEWESTVERSION As Long = &H10
errcode = URLDownloadToFile(0, url, localFileName, BINDF_GETNEWESTVERSION, 0)
Re: Weird download problem
Well, that's odd, it still downloaded the same image twice :(
Code:
Dim Hour As Integer
Private Declare Function URLDownloadToFile Lib "urlmon" Alias _
"URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, _
ByVal szFileName As String, ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long
Dim errcode As Long
Dim url As String
Dim localFileName As String
Private Const BINDF_GETNEWESTVERSION As Long = &H10
Private Sub StartBtn_Click()
Dim CDT As String
Dim CDT1 As String
Dim CDT2 As String
CDT = Now
CDT1 = Replace(CDT, "/", "-")
CDT2 = Replace(CDT1, ":", ".")
url = "http://www.goes.noaa.gov/sohemi/sohemiloops/ircolgms/8.jpg"
localFileName = "C:\Loops\" & CDT2 & ".jpg"
errcode = URLDownloadToFile(0, url, localFileName, BINDF_GETNEWESTVERSION, 0)
If errcode = 0 Then
Label3.Caption = "Download Successful"
Label1.Caption = "Last download: " & Now
Else
Label3.Caption = "Error Downloading"
Label1.Caption = "Failed download: " & Now
End If
Timer1.Enabled = True
End Sub
Private Sub Stop_Click()
Timer1.Enabled = False
Hour = 0
End Sub
Private Sub Timer1_Timer()
Hour = Hour + 1
Label2.Caption = "Seconds until next image: " & 3600 - Hour
If Hour = 3600 Then
Hour = 0
Dim CDT As String
Dim CDT1 As String
Dim CDT2 As String
CDT = Now
CDT1 = Replace(CDT, "/", "-")
CDT2 = Replace(CDT1, ":", ".")
url = "http://www.goes.noaa.gov/sohemi/sohemiloops/ircolgms/8.jpg"
localFileName = "C:\Loops\" & CDT2 & ".jpg"
errcode = URLDownloadToFile(0, url, localFileName, BINDF_GETNEWESTVERSION, 0)
If errcode = 0 Then
Label3.Caption = "Download Successful"
Label1.Caption = "Last download: " & Now
Else
Label3.Caption = "Error Downloading"
Label1.Caption = "Failed download: " & Now
End If
End If
End Sub
Regards,
Dan
Re: Weird download problem
I don't use that API function, but any official documentation I can find on MSDN indicates BINDF_GETNEWESTVERSION is not used with URLDownloadToFile but with URLDownloadToCacheFile instead.
The "command2" example at this link, clears the cache first then downloads the target. Note that example is also using BINDF_GETNEWESTVERSION & maybe improperly.
Re: Weird download problem
Hmm, I tested BINDF_GETNEWESTVERSION with URLDownloadToFile a while ago and it worked fine.
It is also used on vbnet.mvps.org.
http://vbnet.mvps.org/index.html?cod...loadtofile.htm
Re: Weird download problem
Hmm, seems to be working now. Looks like it only saves duplicates of the first 2 images.
Cheers,
Dan
Re: Weird download problem
i had a similar problem downloading updated vb6 exe, using firefox
so i made a small app using urldownloadtofile, to clear cache and always download the new version of exe
worked fine for me