Adding a Line to the Middle of a File with .NET

后端 未结 6 1193
你的背包
你的背包 2020-12-03 21:45

Hello I am working on something, and I need to be able to be able to add text into a .txt file. Although I have this completed I have a small problem. I need to write the st

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-03 22:40

    If you know the line index use readLine until you reach that line and write under it. If you know exactly he text of that line do the same but compare the text returned from readLine with the text that you are searching for and then write under that line.

    Or you can search for the index of a specified string and writ after it using th escape sequence \n.

提交回复
热议问题