READ FILES FROM URL

Ankita Pandey

Total Post:183

Points:1285
Posted by  Ankita Pandey
 1127  View(s)
Ratings:
Rate this:
Hi Developers, 

Is it possible to read files like .css and .js from a URL? For instance, I have a file, which is located at http://main/shared/css/main.css, and want to read this file and store its content in another file at c:\main.txt. I know how to read files in local drives but not sure how to do it for a URL. Any help is much appreciated.

Any help would be amazing thank you!

  1. Vijay Shukla

    Post:100

    Points:700
    Re: Read files from URL

    Hi Ankit,


    Using XMLHttpRequest, you can read the files from the URL as following line of code

    url = "http://main/shared/css/main.css"

    Set req = CreateObject("Msxml2.XMLHttp.6.0")
    req.open "GET", url, False
    req.send

    If req.Status = 200 Then
      Set fso = CreateObject("Scripting.FileSystemObject")
      fso.OpenTextFile("C:\main.txt", 2).Write req.responseText
    End If

    I hope it  helpful for you. 

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!