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

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 OpenAsTextStream 方法


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

The OpenAsTextStream method opens the specified file and returns a TextStream object to access the file.
ASP OpenAsTextStream的作用是打开指定的文件并返回一个文本对象以访问文件。

Syntax
语法

FileObject.OpenAsTextStream(mode,format)

Parameter参数 Description描述
mode Optional. How to open the file.
可选参数。指明打开文件的方式
  • 1 = ForReading - Open a file for reading. You cannot write to this file
    • 1 = 以阅读方式打开(ForReading) - Open a file for reading. You cannot write to this file。| 打开一个文件然后进行阅读,你不可以向此文件中写入内容
  • 2 = ForWriting - Open a file for writing
    • 2 = 以书写方式打开(ForWriting) - Open a file for writing | 打开一个文件并向其中书写内容。
  • 8 = ForAppending - Open a file and write to the end of the file
    • 8 = 以添加方式打开(ForAppending) - Open a file and write to the end of the file | 打开一个文件,并在其文本的最末端追加文本。
format Optional. The format of the file.
可选参数。指明文件的形式
  • 0 = TristateFalse - Default. Open the file as ASCII
    • 0 = TristateFalse - Default. Open the file as ASCII | 默认方式。以ASCII的形式打开文件。
  • -1 = TristateTrue - Open the file as Unicode
    • -1 = TristateTrue - Open the file as Unicode | 以Unicode的形式打开文件。
  • -2 = TristateUseDefault - Open the file using the system default 
    • -2 = TristateUseDefault - Open the file using the system default | 以系统默认的形式打开文件。

Example
举例

<%
dim fs,f,ts
set fs=Server.CreateObject("Scripting.FileSystemObject")
Set f=fs.GetFile("c:test.txt")
Set ts=f.OpenAsTextStream(ForWriting)
ts.Write("Hello World!")
ts.Close
Set ts=f.OpenAsTextStream(ForReading)
Response.Write(ts.ReadAll)
ts.Close
set ts=nothing
set f=nothing
set fs=nothing
%>

Output:

Hello World!

评论 (0) All

登陆 | 还没注册?