Home > DeveloperSection > Forums > Read files from URL
Ankita Pandey
Ankita Pandey

Total Post:183

Points:1285
Posted on    June-20-2013 1:33 AM

 VB Script VB Script 
Ratings:


 1 Reply(s)
 868  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!



Vijay Shukla

Total Post:100

Points:700
Posted on    June-20-2013 5:06 AM

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. 

Don't want to miss updates? Please click the below button!

Follow MindStick