用streamreader读文本的时候能否将 ";" 开头一行的文字整行过滤掉呢?
StreamReader sr = new StreamReader("post.txt");
string content = sr.ReadToEnd();
sr.Close();
textBox1.Text = content;如何改写呢
StreamReader sr = new StreamReader("post.txt");
string content = sr.ReadToEnd();
sr.Close();
textBox1.Text = content;如何改写呢
string content="";
string conline;
while(sr.Peek() >= 0)
{
conline=sr.ReadLine();
if(conline.indexOf(";")!=0)
content+=conline;
}
sr.Close();
textBox1.Text = content;
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();
{
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 ();
}完结