如何更新文本文件中的特定行

  • I have text file that has a line structure as follows: element1,element2,element3 per line.
  • I have a dynamic variable called int Id
  • I have another dynamic variable called string NewText
  • I want to be able to edit a specific line based on whether element3 = id and then update element1 with newText

So for example let's say that the line in the text file looks like this: Sometext,0,1, and int Id = 1 and string NewText = ABC, the output of the updated line should be ABC,0,1.

任何帮助将非常感激。

评论