jejacks0n
Jan 29th, 2001, 01:10 PM
Ok, here's the situation..
I want to download multiple files using the http protocol.
I know how to download a webpage and save it to a file using the inet.openURL/byteArray method, I know how to ftp files using the inet.execute "get/put" commands, and I know how to do a dialog free download.
But I'm unsatisfied using any of these methods to download an actual file (something larger then 10k) using http. Perhaps there is an easy answer that I've just overlooked, but...
Anyway, here are the methods that I've tried. This is a nice tutorial even if I don't get an answer. =).
Dialog Free Download method:
This is nice, it's fast and useful for small files, but it disables the form while the file is being transfered. This means if it's downloading a large file it will halt the form altogether until it's completed that download. Not very useful for what I need.
This is the code and usage, if there's any way to fix this please post.
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
For i = 0 to totaldownload
DownloadFile ("http://foobar.file" & i, "c:\bleah.file")
Next i
Public Function DownloadFile(URL As String, LocalFilename As _
String) As Boolean
Dim lngRetVal As Long
lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
If lngRetVal = 0 Then DownloadFile = True
End Function
Inet.OpenURL method:
This works nicely, you can add a progress bar and trap any errors, but writing to the file takes almost as long as the download time. If you remove the "DoEvents" from the For/Next statement it's a bit faster but still takes a long time. This is very usefull if you are downloading a web page document or something small, but not for larger files.
Code and usage. Any suggestions?
Dim byte As String
Dim b() As Byte
Dim o As Long
For i = 0 to totaldownload
b() = Inet.OpenURL("http://foobar.file" & i, icByteArray)
Open "c:\bleah.file" For Output As #1
For o = 0 To UBound(b) - 1
DoEvents
byte = byte + Chr(b(o))
Next o
Print #1, byte
Close #1
Next i
I want to download multiple files using the http protocol.
I know how to download a webpage and save it to a file using the inet.openURL/byteArray method, I know how to ftp files using the inet.execute "get/put" commands, and I know how to do a dialog free download.
But I'm unsatisfied using any of these methods to download an actual file (something larger then 10k) using http. Perhaps there is an easy answer that I've just overlooked, but...
Anyway, here are the methods that I've tried. This is a nice tutorial even if I don't get an answer. =).
Dialog Free Download method:
This is nice, it's fast and useful for small files, but it disables the form while the file is being transfered. This means if it's downloading a large file it will halt the form altogether until it's completed that download. Not very useful for what I need.
This is the code and usage, if there's any way to fix this please post.
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
For i = 0 to totaldownload
DownloadFile ("http://foobar.file" & i, "c:\bleah.file")
Next i
Public Function DownloadFile(URL As String, LocalFilename As _
String) As Boolean
Dim lngRetVal As Long
lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
If lngRetVal = 0 Then DownloadFile = True
End Function
Inet.OpenURL method:
This works nicely, you can add a progress bar and trap any errors, but writing to the file takes almost as long as the download time. If you remove the "DoEvents" from the For/Next statement it's a bit faster but still takes a long time. This is very usefull if you are downloading a web page document or something small, but not for larger files.
Code and usage. Any suggestions?
Dim byte As String
Dim b() As Byte
Dim o As Long
For i = 0 to totaldownload
b() = Inet.OpenURL("http://foobar.file" & i, icByteArray)
Open "c:\bleah.file" For Output As #1
For o = 0 To UBound(b) - 1
DoEvents
byte = byte + Chr(b(o))
Next o
Print #1, byte
Close #1
Next i