用streamreader读文本的时候能否将 ";" 开头一行的文字整行过滤掉呢?
            StreamReader sr = new StreamReader("post.txt");
            string content = sr.ReadToEnd();
            sr.Close();
            textBox1.Text = content;如何改写呢

解决方案 »

  1.   

    StreamReader sr = new StreamReader("post.txt");
                string content="";
    string conline;
    while(sr.Peek() >= 0)
    {
        conline=sr.ReadLine();
        if(conline.indexOf(";")!=0)
           content+=conline;
    }
                sr.Close();
                textBox1.Text = content;
      

  2.   

    StreamReader sr = new StreamReader("post.txt");
    StringBuilder sb = new StringBuilder();
                string content = sr.ReadLine();
    while(content != null)
    {
      if(!content.StartWith(";"))
    {
      sb.Append(content)
    }
    content = sr.ReadLine();}
                sr.Close();
                textBox1.Text = sb.ToString();
      

  3.   

    StreamReader sr = new StreamReader("post.txt");
                {
                    string content = "";
                    string conline;
                    while (sr.Peek() >= 0)
                    {
                        conline = sr.ReadLine();
                        if (conline.IndexOf(";") != 0)
                            content += "\r\n" + conline;
                    }
                    sr.Close();
                    textBox1.Text = content.ToString ();
                }完结