获取文本文件的行数 -C#文章(.net)
[
2008-7-11 22:55:00
| 发表者 :
zihe
]
现有一个文本文件,要求一行一行读出来,但是我们预先不知道到底有多少行,那么怎么才能正确读出所有行呢?用特定结束字符?
答案一
Function ReadEntireFile(filespec)
Const ForReading = 1
Dim fso, theFile, retstring
Set fso = CreateObject("Scripting.FileSystemObject")
Set theFile = fso.OpenTextFile(filespec, ForReading, False)
Do While theFile.AtEndOfLine <> True
retstring = theFile.Read(1)
Loop
theFile.Close
ReadEntireFile = retstring
End Function
答案二
哈哈,我不喜欢VB,只用Javascript,况且只在客户端用,即可。
上一篇:
C#制作控件的问题 -C#文章(.net) 下一篇:
asp中关于从数据库中读取数据的问题,高手帮忙啊! -C#文章(.net)