Remove String Line If Contains Specific Word C#

Hey, I am working on a game launcher (BY THE WAY IN C#). I have a .txt file stored on a database and unity gets the address of where the .txt file is stored and reads it, then converts it into a string. What I need help with is trying to find in the string, a word (lets call it) ‘Old Version’, and then remove that entire line where ever the word ‘Old Version’ appears.

I’m having issues with using myString.Contains(parameters & parameters), & myString.Replace(parameters, parameters) because I can’t seem to delete the rest of the line, only the “word” which is in the ‘Contains’. Any help is much appreciated! - Trentos El Bartos!

Well, you don’t really show how you’ve loaded the file, but it’ll be easier to remove a “line” of data if you store the lines individually. I’d probably do it something like this:

string searchFor = "Old Version";
string[] lines = File.ReadAllLines(@"c:\yourfile.txt");

for (int i = lines.Count - 1; i >= 0; i--)
{
    if (lines_.Contains(searchFor) { lines.RemoveAt*; }*_

}
Now, “lines” will contain your loaded lines (in an array) minus the line(s) that contain the search string.
It’s not clear whether you want to store the modified file, or just have a modified string “in memory”.
To write the modified array to a file, just do:
File.WriteAllLines(@“c:\your_new_file.txt”, lines);
To create an in-memory string with the array, you want something like:
string content = string.Join(" ", lines);
Or, maybe…
string content = string.Join("
", lines);

Depending on what format you want…
Caution - all code typed directly into the forum and untested…