GS
2014-03-24 17:09:38 UTC
This is what I came up with for downloading multiple files after
looking at various examples. This uses Microsoft.XMLHTTP and
Adodb.Stream as opposed to Scripting.FileSystemObject!
<Script>
Option Explicit
' Downloads listed files from a specified URL folder,
' to a pre-existing folder of a specified path.
Dim vF, oAdoStream, oXmlHttp
Set oXmlHttp = createobject("Microsoft.XMLHTTP")
Set oAdoStream = createobject("Adodb.Stream")
Const DnldURL = "http://www.mywebsite.com/downloads/"
Const DnldFLDR = "C:\MyMainFolder\MySubfolder\"
Const appFILES = "File1,File2,File3,File4"
'Download Deps
For Each vF In Split(appFILES, ",")
oXmlHttp.Open "GET", DnldURL & vF, False
oXmlHttp.Send
With oAdoStream
.Type = 1 '//binary
.Open: .Write oXmlHttp.responseBody
.SaveToFile DnldFLDR & vF, 2 '//overwrite
.Close
End With '//oAdoStream
Next '//vF
'Cleanup
Set oXmlHttp = Nothing: Set oAdoStream = Nothing
</Script>
Does anyone have an opinion as to whether Scripting.FileSystemObject
might be better, and/or pros/cons of either?
looking at various examples. This uses Microsoft.XMLHTTP and
Adodb.Stream as opposed to Scripting.FileSystemObject!
<Script>
Option Explicit
' Downloads listed files from a specified URL folder,
' to a pre-existing folder of a specified path.
Dim vF, oAdoStream, oXmlHttp
Set oXmlHttp = createobject("Microsoft.XMLHTTP")
Set oAdoStream = createobject("Adodb.Stream")
Const DnldURL = "http://www.mywebsite.com/downloads/"
Const DnldFLDR = "C:\MyMainFolder\MySubfolder\"
Const appFILES = "File1,File2,File3,File4"
'Download Deps
For Each vF In Split(appFILES, ",")
oXmlHttp.Open "GET", DnldURL & vF, False
oXmlHttp.Send
With oAdoStream
.Type = 1 '//binary
.Open: .Write oXmlHttp.responseBody
.SaveToFile DnldFLDR & vF, 2 '//overwrite
.Close
End With '//oAdoStream
Next '//vF
'Cleanup
Set oXmlHttp = Nothing: Set oAdoStream = Nothing
</Script>
Does anyone have an opinion as to whether Scripting.FileSystemObject
might be better, and/or pros/cons of either?
--
Garry
Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
Garry
Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion