Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

equivalent to php readfile?

Status
Not open for further replies.

tiamat2012

Programmer
Dec 12, 2004
144
0
0
US
Anyone know something that does it? I can use include, but I think a readfile would be better, and the files I will be reading/including have a query string on them.

Sincerely,
Kerry
 
Hi, i've used:

Set objXML = CreateObject("MSXML2.ServerXMLHTTP")
objXML.open "GET", " false
objXML.send
strContent = objXML.responseText
Set objXML = nothing

to read the contents of a page into a variable. Hope this helps.
 
You can also use the filesystem object.

Code:
dim readtext
Set FS = Server.CreateObject("Scripting.FileSystemObject")
Set RS = FS.OpenTextFile(Server.MapPath("text") & "\test.txt",1)
While not RS.AtEndOfStream
  readtext = RS.ReadLine()
  response.write readtext & "<br>"
Wend

The content of whatever you read in may have to be altered depending on what you do with it. For instance outputing it to the screen may result in odd behavior if the content contains markup that the browser tries to interpret.

Or if the data contains quotes and you try to work with it in ASP the quotes might screw up your string so you would have to escape any characters that might cause you issues. It all depends on the data and what you do with it.


At my age I still learn something new every day, but I forget two others.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top