private void ReadFromFile_Click(object sender, EventArgs e)
        {
            // Clear the listBox
            listBox1.Items.Clear();            /* Create a new StreamReader and pass the file
            created in the WriteToFile_Click event */
            StreamReader sr = new StreamReader(@"C:\FilesCS.txt");            /* Use the Peek method to move to the next character
                and the ReadLine method to get the next line */
            do
            {
                listBox1.Items.Add(sr.ReadLine()); //偶这里有问题问,readline 是否把指针挪动到行尾呢
   //比如 ,文件内容   
  //   sss
  //  aaa
  //那么第一次读完readline()之后,指针是指向最后一个s还是下一个a呢
  //sr.peek()挪动指针的位置么?
  //谢谢。
            }
            while (sr.Peek() != -1);            // Close the StreamReader
            sr.Close();
        }

解决方案 »

  1.   

     listBox1.Items.Add(sr.ReadLine()); //偶这里有问题问,readline 是否把指针挪动到行尾呢
    sr.ReadLine()
    我们知道 在底层C里面没有string 所以都是char[]所以 当有一个\n时候就算1行(\0整个string结束)
    所以就是
    指针移动到\n的下一个这里
             //比如 ,文件内容   
                              //   sss
                              //  aaa
                              //那么第一次读完readline()之后,指针是指向最后一个s还是下一个a呢
                              //sr.peek()挪动指针的位置么?
                              //谢谢。所以当然是移动道a
    sr.peek()貌似是seek() 就是定位指针····定位到某个char 上