Hello!
The problem is this - you need to open the Html-file for reading to find the desired line, replace it with another one and write to the file. I do it while nothing happens
FileStream fi = new FileStream(@"C:\CP1.html", FileMode.OpenOrCreate, FileAccess.ReadWrite); StreamReader rea = new StreamReader(fi); StreamWriter wri = new StreamWriter(fi,false, System.Text.Encoding.GetEncoding(1251)); string time = GetTime(); string t = "<tr><td>" + time +"</td> <td>" + Convert.ToString(Mheight) + "</td> <td>" + Convert.ToString(Mspeed) + "</td> <td>" + Convert.ToString(Mtemp)+ "</td> </tr>"; int i=0; do { i++; string str = rea.ReadLine(); if (str == "<tr class=news-znak>") { str = str.Replace("<tr class=news-znak>", t); wri.WriteLine(str); wri.WriteLine("<tr class=news-znak>"); goto label1; } } while (rea.Peek() != -1); label1: rea.Close(); wri.Close();
What could be the error?
<tr class='news-znak'>
at least) - zb<tr class='news-znak'>