开发者

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. Code below.

<%

Dim fs
set fs = Server.CreateObject("Scripting.FileSystemObject")
fs.CopyFile "http://domain.com/file.xml","softvoyage.xml"
s开发者_开发百科et fs = Nothing

%>DONE.


The FileSystemObject is made for local disc files ONLY. 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


I don't believe the CopyFile method can copy files from http sources. The only examples i've ever seen for the source parameter are for files on the local file system:

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

If you need to save data from an http request, check out the IXMLHTTPRequest object.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜