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

ASP
ASP Drive
ASP File
ASP Folder
ASP Dictionary
ASP ADO
ASP AdRotator
ASP BrowserCap
ASP Content Linking
ASP Content Rotator
ASP Quick Ref
ASP 摘要
ASP 实例

ASP TextStream


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

The TextStream object is used to access the contents of a text file.
TextStream对象是用来访问一个文本文件的内容的。


Examples
举例

Read textfile
读取文本文件
This example demonstrates how to use the OpenTextFile method of the FileSystemObject to create a TextStream Object. The ReadAll method of the TextStream Object reads from the opened text file.  
这个例子告诉我们如何使用FileSystemObject中的OpenTextFile方法来建立一个TextStream对象。使用TextStream对象中的ReadAll方法来读取已经打开的文本内容。

Read only a part of  a textfile
读取一个文本文件中的一部分内容
This example demonstrates how to only read a part of a TextStream file.
这个例子告诉我们如何读取一个文本文件中的其中一部份内容。

Read one line of a textfile
读取一个文本文件中的其中一行信息
This example demonstrates how to read one line from a TextStream file.
这个例子告诉我们如何读取一个文本文件中的其中一行。

Read all lines from a textfile
读取一个文本文件中的所有行
This example demonstrates how to read all the lines from a TextStream file.
这个例子告诉我们如何读取一个文本文件中的所有行。

Skip a part of a textfile
跳过一个文本文件的一部分内容
This example demonstrates how to skip a specified number of characters when reading the TextStream file.
这个例子告诉我们如何在读取文本文件时跳过一定数量的字符。

Skip a line of a textfile
跳过一个文本文件中的其中一行信息
This example demonstrates how to skip a line when reading the TextStream file.
这个例子告诉我们在读取文本文件内容时,如何跳过其中的一行。

Return line-number
返回行数
This example demonstrates how to return the current line number in a TextStream file.
这个例子告诉我们如何一个文本文件中内容的行数。

Get column number
获取列数
This example demonstrates how to get the column number of the current character in a file.
这个例子告诉我们如何一个文件中的现有字符的列数。


The TextStream Object
Text对象

The TextStream object is used to access the contents of text files.
Text对象是用来访问文本文件的内容的。

The following code creates a text file (c:test.txt) and then writes some text to the file (the variable f is an instance of the TextStream object):
下面的代码创建了一个文本文件(c:test.txt)并且将一个文本写入其中(变量“f”就是这个TextStream对象的一个实例):

<% 
dim fs, f 
set fs=Server.CreateObject("Scripting.FileSystemObject") 
set f=fs.CreateTextFile("c:test.txt",true) 
f.WriteLine("Hello World!")
f.Close
set f=nothing
set fs=nothing
%>

To create an instance of the TextStream object you can use the CreateTextFile or OpenTextFile methods of the FileSystemObject object, or you can use the OpenAsTextStream method of the File object.
你可以使用FileSystemObject对象中的CreateTextFile或者OpenTextFile方法创建TextStream对象的一个实例;同样,你也可以使用文件对象中的OpenAsTextStream创建它。

The TextStream object's properties and methods are described below:
TextStream的属性和使用方法介绍如下:

Properties
属性

Property
属性
Description
描述
AtEndOfLine Returns true if the file pointer is positioned immediately before the end-of-line marker in a TextStream file, and false if not
如果指针直接指向文本文件中“最末一行”的标记前,那么,他返回的值为“真(True)”;否则,它返回的值为“假(False)”。
AtEndOfStream Returns true if the file pointer is at the end of a TextStream file, and false if not
如果指针指向一个文本流的最末端,它返回的值为“真(True)”;否则,他返回的值为“假(False)”
Column Returns the column number of the current character position in an input stream
返回输入的文本流中现有的字符行数
Line Returns the current line number in a TextStream file
返回文本流文件中现有的行数

Methods
方法

Method
方法
Description
描述
Close Closes an open TextStream file
关闭文本流文件
Read Reads a specified number of characters from a TextStream file and returns the result
读出一个文本流文件中的指定数量的字符并返回结果
ReadAll Reads an entire TextStream file and returns the result
读取整个文本流文件并返回结果
ReadLine Reads one line from a TextStream file and returns the result
读取文本流文件中的其中一行并返回结果
Skip Skips a specified number of characters when reading a TextStream file
当读取一个文本流文件时跳过指定数量的字符
SkipLine Skips the next line when reading a TextStream file
跳过下一行读取文本流文件
Write Writes a specified text to a TextStream file
将特定的文本内容写入文本流文件
WriteLine Writes a specified text and a new-line character to a TextStream file
将特定的文本内容和新的一行字符写入文本流文件
WriteBlankLines Writes a specified number of new-line character to a TextStream file
将指定数量的几行字符写入文本流文件

评论 (0) All

登陆 | 还没注册?