| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 561 人关注过本帖
标题:文件读取问题
只看楼主 加入收藏
caijiawei
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:162
专家分:101
注 册:2008-10-7
结帖率:82.14%
收藏
已结贴  问题点数:20 回复次数:2 
文件读取问题
在文件读取的时候这样获取到要读取的文件里的数据的行数啊?
请指教!
谢谢……
搜索更多相关主题的帖子: 文件 
2009-12-21 00:18
yangglemu
Rank: 7Rank: 7Rank: 7
等 级:黑侠
帖 子:273
专家分:521
注 册:2006-9-15
收藏
得分:0 
filestream fs=new filestream("xxx.txt",filemodel.open);

streamreader sr=new streamreader(fs);

string line=sr.readline();

int rows=0;

while(!string.isnotnullorempty)
{
 rows++;
}

consoule.write(rows);

试着挣个威望!
2009-12-21 01:00
jedypjd
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:蒙面侠
威 望:9
帖 子:1096
专家分:4969
注 册:2009-7-27
收藏
得分:20 
程序代码:
using System;
using System.Collections.Generic;
using System.Text;
using  ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            FileStream fs = new FileStream("xxx.txt", FileMode.Open);

            StreamReader sr = new StreamReader(fs);
            int rows = 0;

            string line = sr.ReadLine();

            while (line != null)
            {
                rows++;
                line = sr.ReadLine();
            }


            Console.WriteLine(rows.ToString());

            Console.Read();
        }
    }
}

天涯无岁月,歧路有风尘,百年浑似醉,是非一片云
2009-12-21 11:30
快速回复:文件读取问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018104 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved