Advertise with us

Read files from URL

Posted by  Ankita Pandey
 1930  View(s)
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. 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") "GET", url, False
    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. 

      Modified On Mar-30-2018 04:23:26 AM