|
-
Sep 2nd, 2010, 05:29 AM
#1
Thread Starter
Member
Weird download problem
Hi, I am making a small application to automatically download an image that updates every hour. It works, except the application seems to download duplicates of the same image, even though when I visit the URL myself, it shows the newest image.
I thought something might have been in the cache, and it was just using that instead. I have inserted some cache clearing code, however was just wondering (While I wait for the hour ) if anyone had any other idea's as to why it would do this?
My code (without cache clearing stuff)
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 Sub StartBtn_Click()
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, 0, 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
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
|