<%
' Overwrites the contents of File.txt with 2 lines of text.
FileWrite server.mappath("/New Folder/File.txt", _
"line 1" & vbCrLf & "line 2" & vbCrLf, _
True)
' Appends 2 lines of text to the the contents of File.txt.
FileWrite server.mappath("/New Folder/File.txt", _
"line 1" & vbCrLf & "line 2" & vbCrLf, _
False)
%>
<%
Private Sub FileWrite(byVal pathname, byVal strToWrite, byVal boolOverWrite)
dim objFSO, objFile, boolErr, strErrDesc, lngWriteMethod
On Error Resume Next
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
if boolOverWrite then
lngWriteMethod = 2
else
lngWriteMethod = 8
end if
Set objFile = objFSO.OpenTextFile(pathname, lngWriteMethod, False)
objFile.Write strToWrite
If Err Then
boolErr = True
strErrDesc = Err.Description
End If
objFile.Close
Set objFile = Nothing
Set objFSO = Nothing
On Error GoTo 0
if boolErr then Err.Raise 5107, "FileWrite Statement", strErrDesc
End Sub
%>