本来想发源码的 但是百度屏蔽了。自己敲吧 我还特意换了个号来回复, 这个我以前也写了好久。
private void button1_Click(object sender, EventArgs e)
{
int n = 3;//处理第几行
string f = @"D:\test.txt";
StreamReader sr = new StreamReader(f);
string[] all = sr.ReadToEnd().Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
string line3 = all[n - 1];
string[] ss = line3.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
int n0 = Convert.ToInt32(ss[1]) + 1;//加1
sr.Close();
StreamWriter sw = new StreamWriter(f, false);
string wl = "";
for (int i = 0; i < all.Length; i++)
{
if (i == n - 1)
{
wl = ss[0] + " " + n0.ToString();
}
else
wl = all[i];
sw.WriteLine(wl);
}
sw.Flush();
sw.Close();
MessageBox.Show("ok");
}