Reputation: 7758
I get an Object Required error message when the following code runs. Can any help please, classic ASP isn't my strong point.
<%
Function WriteToFile(strFile, strContent)
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
' Second argument: 0 = reading, 1 = writing, 8 = appending
' Third argument: True = create file if it doesn't exist, false = dont
Set objTextFile = objFSO.OpenTextFile(strFile, 8, True)
objTextFile.Write strContent
objTextFile.Close
Set objTextFile = Nothing
Set objFSO = Nothing
End Function
Call WriteDataToFile("test.txt", "test")
%>
Upvotes: 0
Views: 591
Reputation: 1167
Not sure on which line you are getting the error, but try using Server.MapPath():
Set objTextFile = objFSO.OpenTextFile(Server.MapPath(strFile), 8, True)
so that the application knows where to create/locate the file.
Upvotes: 1