更新时间:2023-01-15 17:48:33
使用此代码,这可能对您有帮助
use this code , this may helps you
//Read all lines from the file
string[] data=File.ReadAllLines("myfile.txt");
//replace the first line with your data.
data[0] = "my own text";
//write all data again into the file.
File.WriteAllLines("myfileout.txt", data);
谢谢
--RA
Thanks
--RA
string[] lines = File.ReadAllLines("file.txt");
lines[0]="New Line to overwrite";
File.WriteAllLines("file.txt", lines );