从webdav服务器下载文件

时间:2018-10-22 10:27:39

标签: http vbscript xmlhttprequest webdev.webserver

我的VBScript如下:

Dim myURL 
Dim password
Dim username 
myURL = "https://webdav.pcloud.com/Public%20Folder/d.txt" ' change your URL here...
username = "xyz@gmail.com"
password = "xyzpassword"

Dim HttpReq 
Set HttpReq = CreateObject("Microsoft.XMLHTTP")
HttpReq.Open "GET", myURL, False, "username", "password"
HttpReq.send
myURL = HttpReq.responseBody
If HttpReq.Status = 200 Then
    Set oStrm = CreateObject("ADODB.Stream")
    oStrm.Open
    oStrm.Type = 1
    oStrm.Write HttpReq.responseBody
    oStrm.SaveToFile "C:\d.txt", 2 ' change your path here...
    oStrm.Close
End If

运行该文件时未检测到错误,但该文件未下载到我的PC上。

1 个答案:

答案 0 :(得分:0)

  

从用户名和密码中删除“。

Dim myURL 
Dim password
Dim username 
myURL = "https://webdav.pcloud.com/Public%20Folder/d.txt" ' change your URL here...
username = "xyz@gmail.com"
password = "xyzpassword"

Dim HttpReq 
Set HttpReq = CreateObject("Microsoft.XMLHTTP")
HttpReq.Open "GET", myURL, False, username, password
HttpReq.send
myURL = HttpReq.responseBody
If HttpReq.Status = 200 Then
    Set oStrm = CreateObject("ADODB.Stream")
    oStrm.Open
    oStrm.Type = 1
    oStrm.Write HttpReq.responseBody
    oStrm.SaveToFile "C:\d.txt", 2 ' change your path here...
    oStrm.Close
End If
相关问题