Latest web development tutorials

ASP Read Method

TextStream Object Reference Complete TextStream Object Reference

Read method reads a specified number of characters from a TextStream file and returns the result as a string.

grammar

TextStreamObject.Read(numchar)

参数 描述
numchar 必需的。需从文件中读取字符的数目。

Examples

<%
dim fs,f,t,x
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.CreateTextFile("c:\test.txt")
f.write("Hello World!")
f.close

set t=fs.OpenTextFile("c:\test.txt",1,false)
x=t.Read(5)
t.close
Response.Write("The first five characters are: " & x)
%>

输出:

The first five characters are: Hello


TextStream Object Reference Complete TextStream Object Reference