Basically I have a text file that I read in and display in a rich text box, which is fine, but I then want to be able to search through the text for a specific word and delete the whole line of text that contains this word. I can search through the text to see if the word exists or not but I cannot figure out how to delete the whole line. Any help would be great.
Share
The easiest is to rewrite the whole file without the line(s) that contain the word. You can use
LINQfor that:If you only want to delete all lines that contain the word(not only the sequence of characters), you need to split the line by
' ':