【问题标题】:Download file from webdav server从 webdav 服务器下载文件
【发布时间】:2019-03-26 09:36:05
【问题描述】:

我的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

我运行它时没有检测到错误,但文件没有下载到我的电脑上。

【问题讨论】:

  • 使用 MsgBox 查看脚本内部发生了什么

标签: http vbscript xmlhttprequest webdev.webserver


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-09-28
    • 1970-01-01
    • 1970-01-01
    • 2013-08-30
    • 2017-07-06
    相关资源
    最近更新 更多