WritingFiles.txt

txtwrite.asp

whichFN=server.mappath("/upload/tests/tempfile.txt")

' first, create the file out of thin air
Set fstemp = server.CreateObject("Scripting.FileSystemObject")
Set filetemp = fstemp.CreateTextFile(whichFN, true)
' true = file can be over-written if it exists
' false = file CANNOT be over-written if it exists

filetemp.WriteLine("This is a brand new file!!!!")
filetemp.writeblanklines(3) 
filetemp.WriteLine("This is the last line of the file we created!")
filetemp.Close

' Now open it and add some lines
forappending =8
set filetemp=fstemp.OpentextFile(whichFN, forappending)
filetemp.writeline "a line we added later"
filetemp.writeline "another line we added later..."
filetemp.close

set filetemp=nothing
set fstemp=nothing

If  err.number=0 then
      response.write "File was appended sucessfully!"
else
      response.write "VBScript Errors Occured!
" response.write "Error Number=#" & err.number & "
" response.write "Error Desc. =" & err.description & "
" response.write "Help Path =" & err.helppath & "
" response.write "Native Error=" & err.nativeerror & "
" response.write "Error Source =" & err.source & "
" response.write "SQL State=#" & err.sqlstate & "
" end if