Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

ASP OpenTextFile Method

ASP OpenTextFile Method


FileSystemObject Reference Complete FileSystemObject object reference manual


The OpenTextFile method opens a specified file and returns a TextStream object that can be used to access the 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 - 打开文件用于读取数据。您无法向此文件写数据。       

 2=ForWriting - 打开文件用于写数据。       

 8=ForAppending - 打开文件,并向文件的末尾写数据。 |

| create | Optional. Sets whether to create a new file if the file name does not exist. True indicates a new file can be created; False indicates it 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

%>


FileSystemObject Reference Complete FileSystemObject object reference manual