appending to a text file from asp
gchristy | Posted 7:08pm 24. November 2007 Server Time |
I am trying to append a text file from the following code. The code works okay but I need each new entry to begin at another line. At present the code appends at the end of the previous text. I would like for it to complet the two entries on the same line, then start a new line for each following entry. Can someone give me a push in the right direction?
<%
function WriteToFile(FileName, Contents, Append)
on error resume next
if Append = true then
iMode = 8
else
iMode = 2
end if
set oFs = server.createobject("Scripting.FileSystemObject")
set oTextFile = oFs.OpenTextFile(FileName, iMode, True)
oTextFile.Write Contents
oTextFile.Close
set oTextFile = nothing
set oFS = nothing
end function
%>
<HTML>
<BODY>
<%ststime= now%>
<%ename="greg"%>
<%WriteToFile "C:\Inetpub\wwwroot\Oncall\log.txt", ststime , True%>
<%WriteToFile "C:\Inetpub\wwwroot\Oncall\log.txt", ename , True%>
Write to File test is complete
</BODY>
</HTML> |