How can I copy an html file to a local drive ?

Discussion in 'ASP General' started by paul fpvt2, Feb 19, 2005.

  1. paul fpvt2

    paul fpvt2 Guest

    How can I copy an html file to a local drive ?
    For example: I would like to copy
    www.mywebsite.mypage.htm to
    c:\inetput\wwwroot\mydir\mypage.htm, can I do that ?

    Thanks.
    paul fpvt2, Feb 19, 2005
    #1
    1. Advertising

  2. paul fpvt2

    McKirahan Guest

    "paul fpvt2" <> wrote in message
    news:029701c516a7$06072c10$...
    > How can I copy an html file to a local drive ?
    > For example: I would like to copy
    > www.mywebsite.mypage.htm to
    > c:\inetput\wwwroot\mydir\mypage.htm, can I do that ?
    >
    > Thanks.


    Try this.

    Option Explicit
    '*
    Const cURL = "www.mywebsite.mypage.htm"
    Const cOUT = "c:\inetput\wwwroot\mydir\mypage.htm"
    '*
    WScript.Echo "Success? " & Fetch(cURL,cOUT)

    Function Fetch(xURL,xOUT)
    On Error Resume Next
    Fetch = False
    Err.Clear
    Dim objXML
    Set objXML = CreateObject("Microsoft.XMLHTTP")
    objXML.Open "GET",xURL,False
    objXML.Send
    Dim strXML
    strXML = objXML.ResponseBody
    If Err.Number <> 0 _
    Or objXML.Status <> 200 Then
    Exit Function
    End If
    Set objXML = Nothing
    Dim objADO
    Set objADO = CreateObject("ADODB.Stream")
    objADO.Type = 1
    objADO.Open
    objADO.Write strXML
    objADO.SaveToFile xOUT,2
    Set objADO = Nothing
    Fetch = Err.Number = 0
    End Function

    It will work with binary files (e.g. images) as well.
    McKirahan, Feb 20, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jon
    Replies:
    5
    Views:
    11,116
    Scott M.
    Jan 17, 2010
  2. shailesh
    Replies:
    1
    Views:
    753
    Tim Golden
    Mar 28, 2007
  3. Ghistos
    Replies:
    1
    Views:
    407
    Eliyahu Goldin
    Jul 14, 2008
  4. wenfu cho
    Replies:
    2
    Views:
    211
    wenfu cho
    Jun 28, 2004
  5. Replies:
    4
    Views:
    118
    drink.the.koolaid
    Oct 11, 2007
Loading...

Share This Page