I am learning C# and I would like some help. With the help of the people on I have managed to achieve editing an .inf file section using a regex, but I would like to keep the original line of text before editing. I have placed the code below and a sample of the .INF data before and if possible what I would like it to look like, but not too bothered with how it will look as long as the data is there.
else if (!chkbxintdial.Checked)
{
var lines = File.ReadAllLines(txtcurrent.Text).ToList();
var regex = new Regex(@"^[00]{2}");
var startFrom = lines.IndexOf("[Destinations]");
//Start replacing from the index of "[Destinations]"
for (int i = startFrom; i < lines.Count; i++)
{
//Assuming the ini section ends at an empty line - stop replacing
if (lines[i].Trim() == string.Empty)
break;
lines[i] = regex.Replace(lines[i], "+");
}
File.WriteAllLines(txtnewtariff.Text, lines);
Sample of what I would like to do.
Original file
[Destinations]
00="International",I,IV
0024195="Gabon Mobiles",I,IMT
0024197="Gabon Mobiles",I,IMT
After Process.
[Destinations]
00="International",I,IV
+="International",I,IV
0024195="Gabon Mobiles",I,IMT
+24195="Gabon Mobiles",I,IMT
0024197="Gabon Mobiles",I,IMT
+24197="Gabon Mobiles",I,IMT