Displaying Source Code(s)
|
|
FileWrite Statement
--------------------------------------------------------------------------------
Description : The FileWrite statement allows writing to a file.
The FileWrite statement has three required arguments: pathname,
texttowrite, and overwrite. The first argument is pathname.
Pathname must be the complete path to an already existing file.
The second argument texttowrite is a string containing the text
to add to the file. To add more than one line of text, use
vbCrLf. The third argument is a boolean representing
overwriting. If the overwrite argument is set to True, the
complete contents of the file is replaced with texttowrite. If
it is set to False, the texttowrite string is appended to the
file's contents.
<%
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
%>
--------------------------------------------------------------------------------
|
|
|