05-09-2006, 11:04 AM
Code:
Public Function DownloadFile(srcFileName As String, targetFileName As String)
Dim Size As Long, Remaining As Long, FFile As Integer, Chunk() As Byte
If Trim(targetFileName) "" Then
If Extension "" Then
If Mid(Extension, 1, 1) = "\" Or Mid(Extension, 1, 1) = "/" Then Extension = Mid(Extension, 2, Len(Extension))
If Mid(Extension, Len(Extension), Len(Extension)) = "\" Or Mid(Extension, Len(Extension), Len(Extension)) = "/" Then Extension = Mid(Extension, 1, Len(Extension) - 1)
If LCase(Dir(App.Path & "\" & Extension, vbDirectory)) LCase(Extension) Then
Call MkDir(App.Path & "\" & Extension)
End If
Else
targetFileName = targetFileName
End If
frmUpdate.Inet.Execute Path & srcFileName, "GET"
Do While frmUpdate.Inet.StillExecuting
DoEvents
Loop
Size = Val(frmUpdate.Inet.GetHeader("Content-Length"))
Remaining = 0
FFile = FreeFile
If Extension "" Then
Open App.Path & "\" & Extension & "\" & targetFileName For Binary Access Write As #FFile
Else
Open App.Path & "\" & targetFileName For Binary Access Write As #FFile
End If
Do Until Remaining >= Size
If Size - Remaining > 1023 Then
Chunk = frmUpdate.Inet.GetChunk(1024, icByteArray)
Remaining = Remaining + 1024
Else
Chunk = frmUpdate.Inet.GetChunk(Size - Remaining, icByteArray)
Remaining = Size
End If
Put #FFile, , Chunk
If Size > 0 Then frmUpdate.Label4.Caption = Int(Str((Remaining / Size) * 100)) & "%"
Loop
Close #FFile
DoEvents
End If
End Function
thats from GSDs old updater, you should have no problem figuring out what needs to be chhanged around. (frmUpdate and removal of albels you dont have). It downloads the file to your directory and you can read it from there.