Guest_imported
New member
- Jan 1, 1970
- 0
Im new to this and I'm trying to write an asp page to create and write to a text file using the filesystem object. so I wrote three sort of similar function and none work
I constantly get errors: either Activex cant create object or if I add in the server.createobject it tells me that object required 'server'
If anyone has any ideas please let me know.
<%@ Language=VBScript %>
<html>
<body bgcolor="red" background ="flagback.jpg" BGPROPERTIES="fixed">
<center>
<HR>
<Script Language="VBscript">
function Write_in_File()
Myfile = "pleasework.txt"
Set Fs = server.Createobject("Scripting.FileSystemObject"
msgbox MyFile
Set File_Name = Fs.createTextFile(Myfile,2,True)
File_Name.Write TEXT1.value
File_Name.Close
Set File_Name = Nothing
Set Fs = Nothing
End function
Sub cmdSubmit_onclick()
call write_in_file
Call StringToFile(TEXT1.value,"pleasework.txt"
call Session_OnStart
Text1.value = ""
End sub
Function StringToFile(StringToWrite, PathAndFilename)
on error resume next
const ForReading = 1'Open a file for reading only.
const ForWriting = 2' Open a file for writing only.
const ForAppending = 8 ' Open a file and write to the end of the file.
dim stf_fso, stf_File
Set stf_fso = CreateObject("Scripting.FileSystemObject"
If FileExist(PathAndFilename)then
Set stf_File = stf_fspenTextFile(PathAndFilename, ForWriting, True)
msgbox PathAndFilename
Else
Set stf_File = stf_fso.CreateTextFile(PathAndFilename, True)
msgbox "created file"
End if
stf_File.Write strFileData
Set stf_File = nothing
Set stf_fso = nothing
End function
Function FileToString(PathAndFilename)
on error resume next
const ForReading = 1'Open a file for reading only.
const ForWriting = 2' Open a file for writing only.
const ForAppending = 8 ' Open a file and write to the end of the file.
dim stf_fso, stf_File
Set stf_fso = CreateObject("Scripting.FileSystemObject"
If FileExist(PathAndFilename) then
Set stf_File = stf_fspenTextFile(PathAndFilename, ForWriting, True)
Else
Set stf_File = stf_fso.CreateTextFile(PathAndFilename, True)
End if
stf_File.Write strFileData
Set stf_File = nothing
Set stf_fso = nothing
End function
Function Session_OnStart
hits = hits + 1
Set fs = CreateObject("Scripting.FileSystemObject"
set hitfile = fs.CreateTextFile("hits.txt",True,false)
hitfile.WriteLine(Hits)
hitfile.Close
end Function
</script>
</center><TEXTAREA id=TEXT1 name=TEXTAREA1 style="HEIGHT: 104px; WIDTH: 462px">
I constantly get errors: either Activex cant create object or if I add in the server.createobject it tells me that object required 'server'
If anyone has any ideas please let me know.
<%@ Language=VBScript %>
<html>
<body bgcolor="red" background ="flagback.jpg" BGPROPERTIES="fixed">
<center>
<HR>
<Script Language="VBscript">
function Write_in_File()
Myfile = "pleasework.txt"
Set Fs = server.Createobject("Scripting.FileSystemObject"
msgbox MyFile
Set File_Name = Fs.createTextFile(Myfile,2,True)
File_Name.Write TEXT1.value
File_Name.Close
Set File_Name = Nothing
Set Fs = Nothing
End function
Sub cmdSubmit_onclick()
call write_in_file
Call StringToFile(TEXT1.value,"pleasework.txt"
call Session_OnStart
Text1.value = ""
End sub
Function StringToFile(StringToWrite, PathAndFilename)
on error resume next
const ForReading = 1'Open a file for reading only.
const ForWriting = 2' Open a file for writing only.
const ForAppending = 8 ' Open a file and write to the end of the file.
dim stf_fso, stf_File
Set stf_fso = CreateObject("Scripting.FileSystemObject"
If FileExist(PathAndFilename)then
Set stf_File = stf_fspenTextFile(PathAndFilename, ForWriting, True)
msgbox PathAndFilename
Else
Set stf_File = stf_fso.CreateTextFile(PathAndFilename, True)
msgbox "created file"
End if
stf_File.Write strFileData
Set stf_File = nothing
Set stf_fso = nothing
End function
Function FileToString(PathAndFilename)
on error resume next
const ForReading = 1'Open a file for reading only.
const ForWriting = 2' Open a file for writing only.
const ForAppending = 8 ' Open a file and write to the end of the file.
dim stf_fso, stf_File
Set stf_fso = CreateObject("Scripting.FileSystemObject"
If FileExist(PathAndFilename) then
Set stf_File = stf_fspenTextFile(PathAndFilename, ForWriting, True)
Else
Set stf_File = stf_fso.CreateTextFile(PathAndFilename, True)
End if
stf_File.Write strFileData
Set stf_File = nothing
Set stf_fso = nothing
End function
Function Session_OnStart
hits = hits + 1
Set fs = CreateObject("Scripting.FileSystemObject"
set hitfile = fs.CreateTextFile("hits.txt",True,false)
hitfile.WriteLine(Hits)
hitfile.Close
end Function
</script>
</center><TEXTAREA id=TEXT1 name=TEXTAREA1 style="HEIGHT: 104px; WIDTH: 462px">