日期:2014-05-17 浏览次数:20926 次
List<string> line = new List<string>();//声明一个泛型
using (StreamReader sr = new StreamReader("test.txt", Encoding.UTF8))
{
string n;
while ((n = sr.ReadLine()) != null)
{
line.Add(n);
}
}
line.RemoveAt(line.Count - 1);//指定要删除最后一行
StreamWriter sw = new StreamWriter("test.txt", false, Encoding.UTF8);
foreach (string s in line)
sw.WriteLine(s);
sw.Close();