I'm trying to remove lines that are in between two different lines. Currently, I have:
string s = "";
String path = @"C:\TextFile";
StreamWriter sw = new StreamWriter(path, true);
StreamReader sr = new StreamReader(path, true);
s = sr.ReadLine();
if (s=="#Start")
{
while (s != "#End")
{
sw.WriteLine(s);
//need something here to overwrite existing data with s not just add s
}
}
sr.Close();
sw.Close();
The content of my text file looks like this:
#Start
facebook.com
google.com
youtube.com
#End
I tried to follow Efficient way to delete a line from a text file however it deletes any file containing a certain character, whereas there are other lines outside of the range containing .com
that I don't want to remove
I want to delete all the contents in between start and end so after the method runs the remains of the text file is
#Start
#End