且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

替换文本文件中的一行

更新时间:2023-02-23 17:38:56

您应该能够分配该元素:

You should be able to just assign that element:

arrLine[yourLineNumber] = "Foo";




我实际上如何将更改提交到文本文件?

how would i actually commit the change to the text file?

完成此操作后,可以使用 File.WriteAllLines(pathToFile,arrLine); 将数据写回到原始文件。

Once you've done this, you can use File.WriteAllLines(pathToFile, arrLine); to write the data back to the original file.