I am having a problem reading a .txt file off a web page using Microsoft's XMLHTTP method. After reading the the page into a variable called strContents I would like to write the data to a file.
I have the following code but seem to get an error in writing the strContents to a file. When i write a "string" it works fine.
Any suggestions?
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>
<body>
<%
Dim fsoObject 'File System Object
Dim tsObject 'Text Stream Object
Dim strContents
' Introduce the url you want to visit
GotothisURL = "[URL]http://kerrdental.com/inc/data/form_files/kerrdental/warranty.txt[/URL]"
' Create the xml object
Set GetConnection = CreateObject("Microsoft.XMLHTTP")
' Conect to specified URL
GetConnection.Open "get", GotothisURL, False
GetConnection.Send
' ResponsePage is the response we will get when visiting GotothisURL
ResponsePage = GetConnection.responseText
strContents = ResponsePage
' We will write to the page (this works).
Response.write (strContents)
Set fsoObject = Server.CreateObject("Scripting.FileSystemObject")
Set tsObject = fsoObject.CreateTextFile(Server.MapPath("myNewText.txt"))
' tsObject.write ("This is a test")
tsObject.write (strContents)
' tsObject.Write (ResponsePage)
Set fsoObject = Nothing
Set tsObject = Nothing
Set filObject = Nothing
Set GetConnection = Nothing
%>
<p>Testing Writing file.</p>
</body>
</html>