当前位置: 首页 > 网络学院 > 服务端脚本教程 > ASP > ASP OpenTextFile 方法

ASP
ASP 介绍
ASP Install
ASP 语法
ASP 变量
ASP Procedures
ASP Forms
ASP Cookies
ASP Session
ASP Application
ASP #include
ASP Global.asa
ASP Send e-mail
ASP Response
ASP Request
ASP Application
ASP Session
ASP Server
ASP Error
ASP FileSystem
ASP TextStream

ASP OpenTextFile 方法


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 315 ::
收藏到网摘: n/a

The OpenTextFile method opens a specified file and returns a TextStream object that can be used to access the file.
ASP OpenTextFile的作用是打开一个指定的文件或者返回一个能够访问文件的文本流(TextStream)对象。

Syntax
语法

FileSystemObject.OpenTextFile(fname,mode,create,format)

Parameter参数 Description描述
fname Required. The name of the file to open
必要参数。指定需要打开文件的名称
mode Optional. How to open the file
可选组件。规定打开文件的方式

1=ForReading - Open a file for reading. You cannot write to this file.
1=ForReading(以阅读内容为目的) – 打开文件进行内容阅读,但是你不可以在这个文件上书写内容。
2=ForWriting - Open a file for writing.
2=ForWriting(以书写内容为目的)- 打开文件进行内容书写。
8=ForAppending - Open a file and write to the end of the file.
8=ForAppending(以追加内容为目的)- 打开一个文件直接在这个文件内容最后追加内容

create Optional. Sets whether a new file can be created if the filename does not exist. True indicates that a new file can be created, and False indicates that a new file will not be created. False is default
可选组件。设置是否可以建立一个原本不存在的新文件。如果为true真,则可以建立一个新的文件,如果为false假,则不可以建立一个新的文件。默认情况是false假。
format Optional. The format of the file
可选组件。规定文件的格式

0=TristateFalse - Open the file as ASCII. This is default.
0= TristateFalse – 以ASCII形式打开文件。这是原来的默认属性
-1=TristateTrue - Open the file as Unicode.
-1=TristateTrue – 以Unicode形式打开文件
-2=TristateUseDefault - Open the file using the system default.
-2=TristateUseDefault – 使用系统默认的格式打开文件

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
%> 

评论 (0) All

登陆 | 还没注册?