请问怎样可以判断一个TXT文件中有多少行文字?

xwqjamky 2007-01-02 07:34:34
请问怎样可以判断一个TXT文件中有多少行文字?

...全文
839 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
chenxiaoguo20 2007-02-21
  • 打赏
  • 举报
回复
关注下.
wslinfeng 2007-01-23
  • 打赏
  • 举报
回复
晕了,还有这样说别人的
懒牛科技 2007-01-03
  • 打赏
  • 举报
回复
同意HAVENT(夜雨流星℡) 的!
KissXYL 2007-01-03
  • 打赏
  • 举报
回复
xwqjamky(陌上烟花)
你的浏览器有问题么?我上面回复的你看不到?见识什么叫做睁着眼睛说瞎话了。你是女孩吧,虽然我不歧视女性做开发的,的确很多高手是女性,但我见过更多不愿意尝试和不愿意主动动手的女性,比如你这样的。真的很让人头疼的。
xwqjamky 2007-01-03
  • 打赏
  • 举报
回复
请问具体怎样判断回车换行呢?
xwqjamky 2007-01-03
  • 打赏
  • 举报
回复
具体怎样统计呢?
HAVENT 2007-01-03
  • 打赏
  • 举报
回复
可以一次读取完,然后统计其中的回车换行符号的个数
xwqjamky 2007-01-03
  • 打赏
  • 举报
回复
请问具体怎样统计回车换行符呢?能写出来吗?
KissXYL 2007-01-02
  • 打赏
  • 举报
回复
Dim dlg As New OpenFileDialog
dlg.InitialDirectory = "c:\"
dlg.Multiselect = False
dlg.CheckFileExists = True
If dlg.ShowDialog() = Windows.Forms.DialogResult.OK Then
Dim fs As IO.FileStream = dlg.OpenFile()
Dim bzData As Byte()
ReDim bzData(fs.Length)
fs.Read(bzData, 0, fs.Length - 1)
Dim strFileData As String = System.Text.Encoding.ASCII.GetString(bzData)
Dim res As System.Text.RegularExpressions.MatchCollection
res = System.Text.RegularExpressions.Regex.Matches(strFileData, "\r\n")
Dim strRes As String = String.Format("一共有{0:d}行。", res.Count + 1)
MessageBox.Show(strRes)
End If
wslinfeng 2007-01-02
  • 打赏
  • 举报
回复
改下
private int countline(string fullfilename)
{
System.IO.StreamReader sr=new System.IO.StreamReader(fullfilename);
int line=0;
while(sr.ReadLine()!=null)
{
line++;
}
return line;
sr.Close();


}
wslinfeng 2007-01-02
  • 打赏
  • 举报
回复
转下很容易,网上搜个转代码的网站
xwqjamky 2007-01-02
  • 打赏
  • 举报
回复
有没有VB.NET的?
wslinfeng 2007-01-02
  • 打赏
  • 举报
回复
private int countline(string fullfilename)
{
System.IO.StreamReader sr=new System.IO.StreamReader(fullfilename);
int line=0;
while(sr.ReadLine()!=null)
{
line++;
}
return line;


}

主函数调用


private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
int cc=countline(@"c:\1.txt");
Response.Write(cc);
}

VS03测试通过
wslinfeng 2007-01-02
  • 打赏
  • 举报
回复
C#的,要不
我写下

xwqjamky 2007-01-02
  • 打赏
  • 举报
回复
具体怎样写,,请帮忙
wslinfeng 2007-01-02
  • 打赏
  • 举报
回复
用READLINE()一行一行读,
while循环里加个计数器变量,

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧