Delete specific line from a text file?

前端 未结 10 1656
既然无缘
既然无缘 2020-11-29 11:14

I need to delete an exact line from a text file but I cannot for the life of me workout how to go about doing this.

Any suggestions or examples would be greatly appr

10条回答
  •  [愿得一人]
    2020-11-29 11:46

    The best way to do this is to open the file in text mode, read each line with ReadLine(), and then write it to a new file with WriteLine(), skipping the one line you want to delete.

    There is no generic delete-a-line-from-file function, as far as I know.

提交回复
热议问题