ÄúµÄλÖãºÑ°ÃÎÍøÊ×Ò³£¾±à³ÌÀÖÔ°£¾VBScript£¾VBScript


objects constants operators statements functions properties methods







METHOD:  TextStream.Read

object.Read

This method reads the number of characters you specify from a Textstream file and returns them as a string.

Code:
<%
dim filesys, text, readfile, contents
set filesys = CreateObject("Scripting.FileSystemObject")
Set text = filesys.CreateTextFile("c:\somefile2.txt")
text.Write "A quick example of the Read method"
text.close
set readfile = filesys.OpenTextFile("c:\somefile2.txt", 1, false)
contents = readfile.Read(7)
readfile.close
Response.Write "The first seven characters in the text file are '" & contents & "'."
%>

Output:
"The first seven characters in the text file are 'A quick'.