Log in

View Full Version : Resolved fso.OpenTextFile



vb2java
10-21-2011, 07:14 PM
Hello again,

Ok, clearly I was clueless (I am referring to my "SOMETHING" post). I am not quite as lost although I have no idea WHY the following Classic ASP script will not simply write the value of <input type="text" value="firstname" /> to a text file. Take this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>TextBox Process Test</title>

</head>
<body>
</br>
&nbsp; <form action="FirstNameTest.asp" method="Post">
&nbsp; First Name: <input type="text" name="firstname" />
&nbsp; <input type="submit" value="Submit" />
&nbsp; <input type="reset" value="Clear" />
&nbsp;
</body>
</html>


That is called FirstNamePage.asp. The following is FirstNameTest.asp:


THIS PART WORKS

<%
Option Explicit
Dim firstname
firstname = Request.Form("firstname")
response.write firstname

' If I add the following lines, the response.write still works:

Dim fso, txtfile, objFile

textfile = "C:\Inetpub\wwwroot\FolderName\FirstName.txt"
Set fso = Server.CreateObject("Scripting.FileSystemObject")

' AS SOON AS I TRY TO OPEN THE TEXTFILE, I GET ERROR HTTP 500

Set objFile = fso.OpenTextFile(txtfile, 8, True)
objFile.WriteLine firstname
objFile.Close
Set objFile = nothing
Set fso = nothing

%>

Will someone PLEASE help me... pretty please :confused:

vb2java
10-24-2011, 05:20 PM
Hello,

I really wish somone would have responded. I was in a :eek: for too long

HTTP Error 500 is because I had friendly error messages checked in the Advanced Tab of the Internet Options dialog box. I had come acrross that bit of information before (months ago) and had forgotten all about it.

After getting descriptive debugging information, I was able to get my script to work.

:p