ASP Read 方法

定义和用法

Read 方法从 TextStream 文件中读取指定数量的字符,并以字符串返回结果。

语法:

TextStreamObject.Read(numchar)
参数 描述
numchar 必需的。需要从文件中读取字符的数量。

样本

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

Output:

The first five characters are: Hello