I want remove a text if the program finds the text to replace, so I prepared this code:
string[] lines = File.ReadAllLines(@"pathtofile");
int Object = 0;
foreach (string line in lines)
{
if (line.Contains("Object"))
{
MessageBox.Show("contain!");
dsObject++;
}
if (Object == 1)
{
line.Replace("Object", " ");
MessageBox.Show(line);
}
File.AppendAllText(@"savefile.txt", line + Environment.NewLine);
string result = line;
// MessageBox.Show(line);
}
This does not work.