asp读取txt问题

源码如下:

<%
file=server.mappath("2.txt")'操作同一个目录中的文件
Const ForReading = 1, ForWriting = 2
Dim fso, f

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(file, ForReading)
'ReadAllTextFile = f.ReadAll'读出所有内容
'response.write ReadAllTextFile
i=0
Do While f.AtEndOfLine <> True'读出所有的行到数组
i=i+1
ReDim Preserve file_list(i)
file_list(i)=f.ReadLine
loop
Randomize
c=Int((i - 1 + 1) * Rnd + 1)'生成随机数,随机取一行
response.write "取得行号为:"&c&":共"&i&"行<br>"
response.write "行内容:"&file_list(c)

%>

版权声明:
作者:admin
链接:http://www.bttme.com/archives/99.html
来源:bttme
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>