using System.IO; StreamReader vStreamReader = new StreamReader(
    @"C:\你的文件名.txt", Encoding.Default);
string line;
int count = 0;
while ((line = vStreamReader.ReadLine()) != null)
{
    if (line.IndexOf("办公桌_004") >= 0)
        count++;
}
vStreamReader.Close();

解决方案 »

  1.   

    this.label7.Text = ofd.FileName;
                    System.IO.StreamReader reader = new StreamReader(ofd.FileName, System.Text.Encoding.GetEncoding("gb2312"));
                    string line;
                    string content = "";
                    while (reader.Peek() >= 0)
                    {
                        line = reader.ReadLine();
                        char[] chr = line.ToCharArray();
                        for (int i = 0; i <chr.Length - 1; i++)
                        {
                            if (chr[i]=='_')
                            {
                                string[] tmp = line.Split('_');
                                content += tmp[1];
                            }
                        }
                            
                    }
                    textBox5.Text = content;