using System; using System.IO; using System.Text; namespace UsefulFunctions { public class Program { static string _line; static int _linesnum; static void Main() { ReviseFileContent(@"C:UsersAdministratorDesktopmylist.txt"); Console.WriteLine(_linesnum); Console.ReadKey(); } public static void ReviseFileContent(string path) { var sr = new StreamReader(@"C:UsersAdministratorDesktoplist.txt", Encoding.Default); var sw = new StreamWriter(@"C:UsersAdministratorDesktopmylist.txt"); while (!sr.EndOfStream) //是否读到结尾 { if ((_line = sr.ReadLine()) == null) continue; var ss = _line.Split('.'); var s = ss[0] + "S." + ss[1]; sw.WriteLine(s); _linesnum++; } sw.Close(); sr.Close(); } } }