I currently report on the variable stringantiga
the exact value to find and replace it.
Is there any way to substitute for the line number instead of the exact value of stringantiga
?
string arquivo = ConfigurationSettings.AppSettings["Caminho"].ToString();
string stringbusca = "MaxChannelInUse";
string stringantiga = "MaxChannelInUse=80";
string stringnova = "MaxChannelInUse=90000";
StreamReader sr = new StreamReader(arquivo);
StringBuilder sb = new StringBuilder();
while (!sr.EndOfStream)
{
string s = sr.ReadLine();
if (s.IndexOf(stringbusca) > -1)
{
s = s.Replace(stringantiga, stringnova);
}
sb.AppendLine(s);
}
sr.Close();
StreamWriter sw = new StreamWriter(arquivo);
sw.Write(sb);
sw.Close();