简体   繁体   English

VBScript的CopyFile无法正常工作

[英]VBScript's CopyFile not working

I think it may have something to do with the external file but I am getting the error Path not found and don't know why. 我认为它可能与外部文件有关,但我收到错误Path not found ,不知道为什么。 Code below. 代码如下。

<%

Dim fs
set fs = Server.CreateObject("Scripting.FileSystemObject")
fs.CopyFile "http://domain.com/file.xml","softvoyage.xml"
set fs = Nothing

%>DONE.

The FileSystemObject is made for local disc files ONLY. FileSystemObject仅用于本地磁盘文件。 Try this: 尝试这个:

<%
    url = "http://www.espn.com/main.html" 
    set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP") 
    xmlhttp.open "GET", url, false 
    xmlhttp.send "" 
    Response.write xmlhttp.responseText 
    set xmlhttp = nothing 
%>

Found at http://classicasp.aspfaq.com/general/how-do-i-read-the-contents-of-a-remote-web-page.html 发现于http://classicasp.aspfaq.com/general/how-do-i-read-the-contents-of-a-remote-web-page.html

I don't believe the CopyFile method can copy files from http sources. 我不相信CopyFile方法可以从http源复制文件。 The only examples i've ever seen for the source parameter are for files on the local file system: 我见过的关于source参数的唯一例子是本地文件系统上的文件:

FileSystemObject.CopyFile "c:\srcFolder\srcFile.txt", "c:\destFolder\"

If you need to save data from an http request, check out the IXMLHTTPRequest object . 如果需要从http请求保存数据,请查看IXMLHTTPRequest对象

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM