返回行数

代码:

<!DOCTYPE html>

<html>

<body>

<p>This is all the lines in the text file (with line numbers):</p>

 

<%

Set fs=Server.CreateObject("Scripting.FileSystemObject")

Set f=fs.OpenTextFile(Server.MapPath("testread.txt"), 1)

 

do while f.AtEndOfStream = false

Response.Write("Line:" & f.Line & " ")

Response.Write(f.ReadLine)

Response.Write("<br>")

loop

 

f.Close

Set f=Nothing

Set fs=Nothing

%>

 

</body>

</html>

结果:

This is all the lines in the text file (with line numbers):

Line:1 Hello!
Line:2 How are you today?

相关文章