WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Samples from Users

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Use XMLHTTP to Download a File


strFile = StrCat (DirScript (),"wwcpu44i.zip")
strURL = "http://files.winbatch.com/wwwftp/wb01/wwcpu44i.zip"
adTypeBinary = 1
adSaveCreateOverWrite = 2
ForWriting = 2

;Download the file with any available object
ErrorMode(@OFF)
web = CreateObject("WinHttp.WinHttpRequest")
If web == 0
   web = CreateObject("Microsoft.XMLHTTP")
   If web == 0
      web = CreateObject("MSXML2.XMLHTTP")
      If web == 0
         Message("Error","No Support - Invalid Class Strings")
         Exit
      EndIf
   EndIf
EndIf
ErrorMode(@CANCEL)
web.Open("GET", strURL, @FALSE)
web.Send()
result = web.Status
If result <> "200" Then
   Message("Problem Accessing page",result)
   web = 0
   Exit
End If
varByteArray = web.ResponseBody
web = 0
buf = BinaryAllocArray(varByteArray)
data = BinaryWrite(buf, strFile)
BinaryFree(buf)

Message("File Download","Complete")
Exit


Article ID:   W17200
File Created: 2007:07:03:14:28:42
Last Updated: 2007:07:03:14:28:42