在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
解决Node不全面 //使用文件流的方法 public static void EditFile(int curLine, string newLineValue, string patch) { FileStream fs = new FileStream(patch, FileMode.Open, FileAccess.Read); StreamReader sr = new StreamReader(fs, Encoding.GetEncoding("utf-8")); string line = sr.ReadLine(); StringBuilder sb = new StringBuilder(); for (int i = 1; line != null; i++) { sb.Append(line + "\r\n"); if (i != curLine - 1) line = sr.ReadLine(); else { sr.ReadLine(); line = newLineValue; } } sr.Close(); fs.Close(); FileStream fs1 = new FileStream(patch, FileMode.Open, FileAccess.Write); StreamWriter sw = new StreamWriter(fs1); sw.Write(sb.ToString()); sw.Close(); fs.Close(); }
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论