Latest web development tutorials

ASP TextStream Object

TextStream object is used to access the contents of a text file.


Examples

Try - Example

Reading Text Files
This example demonstrates how to read from a text file.

Read a text file in a part
This example demonstrates how to read only part of the contents of a text stream file.

Read a text file line
This example demonstrates how to read a line from a text stream file.

All the line that reads text files
This example demonstrates how to read all the lines from the text stream file.

Skip part of the text file
This example demonstrates how to skip a specified number of characters when reading a text stream file.

Skip a line in the text file
This example demonstrates how to skip a line when reading the text stream file.

Returns the number of rows
This example demonstrates how to return the file in the text flow in the current line number.

Get the number of columns
This example demonstrates how to get the current character in the file column number.


TextStream object

TextStream object is used to access the contents of a text file.

The following code creates a text file (c: \ test.txt), and then write some text to this file (variable f is an instance of the TextStream object):

<%
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, method, or you can use CreateTextFile OpenTextFile method FileSystemObject object, the method can also be used OpenAsTextStream File object.

TextStream object properties and methods are described below:

Attributes

属性 描述
AtEndOfLine 如果文件指针正好位于 TextStream 文件中行尾标记的前面,则该属性值返回 True;否则返回 False。
AtEndOfStream 如果文件指针在 TextStream 文件末尾,则该属性值返回 True;否则返回 False。
Column 返回 TextStream 文件输入流中的当前字符位置的列号。
Line 返回 TextStream 文件中的当前行号。

method

方法 描述
Close 关闭一个打开的 TextStream 文件。
Read 从一个 TextStream 文件中读取指定数量的字符并返回结果。
ReadAll 读取整个 TextStream 文件并返回结果。
ReadLine 从一个 TextStream 文件读取一整行(到换行符但不包括换行符)并返回结果。
Skip 当读取一个 TextStream 文件时跳过指定数量的字符。
SkipLine 当读取一个 TextStream 文件时跳过下一行。
Write 写入指定的文本到一个 TextStream 文件中。
WriteLine 写入指定的文本和换行符到一个 TextStream 文件中。
WriteBlankLines 写入指定数量的换行符到一个 TextStream 文件中。