日期:2014-05-19  浏览次数:20811 次

又一个问题,把dat中文本读出来了,想一行一行的读,高手给指点一下吧
把文本读出来了,可不知道怎么一行一行分开,程序如下:
  static   void   Main(string[]   args)
                {
                        byte[]   m_b   =   new   byte[10000];
                        char[]   m_c   =   new   char[10000];
                        try
                        {
                                FileStream   m_Fs   =   new   FileStream(@ "E:\HuaXia\source\6304-STMT30-20070515.dat ",   FileMode.Open);
                                m_Fs.Seek(0,SeekOrigin.Begin);
                                m_Fs.Read(m_b,0,10000);
                        }
                        catch(IOException   ex)
                        {
                                Console.WriteLine( "there   is   an   IOException ");
                                Console.WriteLine(ex.Message);
                                Console.ReadLine();
                                return;
                        }
                        System.Text.Encoding.GetEncoding( "GB2312 ");
                        Decoder   m_Dec   =   Encoding.Default.GetDecoder();
                        m_Dec.GetChars(m_b,0,m_b.Length,m_c,0);
                        Console.WriteLine( "read   from   file   succed! ");
                        Console.WriteLine(m_c);
                        Console.ReadLine();
                        return;
哪位仁兄给点指点吧,最好能在源程序上加点东本.在线等,马上给分

------解决方案--------------------
要看你.dat文件中具体存放的是什么类型的数据,如果是文本,就直接用楼上的方法,如果你只是想读一千个字节换一行那估计没有太大的意义
------解决方案--------------------
刚此那个写成写流了,应该是以下的这个
FileStream fs = new FileStream( "c:\\updatalog.txt ", FileMode.OpenOrCreate);
StreamReader sw = new StreamReader(fs);
sw.AutoFlush = true;
string data=sw.ReadLine();//这样读一行