ASP ReadLine 方法

定义和用法

ReadLine 方法可从 TextStream 文件中读取一整行字符,并以字符串返回结果。

语法:

  1. TextStreamObject.ReadLine

实例

  1. <%
  2. dim fs,f,t,x
  3. set fs=Server.CreateObject("Scripting.FileSystemObject")
  4. set f=fs.CreateTextFile("c:\test.txt")
  5. f.writeline("Line 1")
  6. f.writeline("Line 2")
  7. f.writeline("Line 3")
  8. f.close
  9.  
  10. set t=fs.OpenTextFile("c:\test.txt",1,false)
  11. x=t.ReadLine
  12. t.close
  13. Response.Write("The first line in the file ")
  14. Response.Write("contains this text: " & x)
  15. %>

输出:

  1. The first line in the file contains this text: Line 1