按行讀取文件: int fileCount=0; // Open the file just specifIEd such that no one else can use it. StreamReader sr = new StreamReader(textBox1.Text.Trim()); while(sr.Peek() > -1)//StreamReader.Peek()返回下一個可用字符,但不使用它 { listBox1.Items.Add(sr.ReadLine()); fileCount++; } sr.Close();