ASP OpenTextFileMethod
Complete FileSystemObject Object Reference Manual
The OpenTextFile method opens a specified file and returns a TextStream object that can be used to access this file.
Syntax
FileSystemObject.OpenTextFile(fname,mode,create,format)
| Parameters | Description |
|---|---|
| fname | Required. The name of the file to open. |
| mode | Optional. How to open the file. 1=ForReading - Opens the file for reading data. You cannot write to this file. 2=ForWriting - Opens the file for writing data. 8=ForAppending - Opens the file and writes data to the end of the file. |
| create | Optional. Sets whether a new file is created if the file name does not exist. True indicates a new file can be created, False indicates a new file will not be created. False is the default. |
| format | Optional. The format of the file. 0=TristateFalse - Opens the file in ASCII. Default. -1=TristateTrue - Opens the file in Unicode. -2=TristateUseDefault - Opens the file using the system default format. |
Example
<%
dim fs,f
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.OpenTextFile(Server.MapPath("testread.txt"),8,true)
f.WriteLine("This text will be added to the end of file")
f.Close
set f=Nothing
set fs=Nothing
%>
dim fs,f
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.OpenTextFile(Server.MapPath("testread.txt"),8,true)
f.WriteLine("This text will be added to the end of file")
f.Close
set f=Nothing
set fs=Nothing
%>
Complete FileSystemObject Object Reference Manual Other Extensions