更新时间:2023-02-23 14:09:28
读取所有文件内容.使用 String.Replace
进行替换.将内容写回文件.
Read all file content. Make a replacement with String.Replace
. Write content back to file.
string text = File.ReadAllText("test.txt");
text = text.Replace("some text", "new value");
File.WriteAllText("test.txt", text);