There is an ini file format
########## Order section ##########
KeyOne=Value1
....
....
....
...
KeyMore=999
Key = 88888*
......
......
......
how can I edit what is behind the = ? I tried in many ways, but since there are no sections in the ini file, I can’t figure out how to change the values Value1 and 999 and 88888*?
Tried splitting strings with split "=" , but failed to change values. and also add new lines to the file? after Key = 88888*
1.If there are spaces or text in the textbox, then it does not work.
const string filepath = @"C:\Users\123\Desktop\Config.ini";
string text = File.ReadAllText(filepath);
const string PATTERN = @"KeyOne=(?<Number>[\d\.]+)";
Match match = Regex.Match(text, PATTERN, RegexOptions.IgnoreCase);
if (match.Success)
{
int index = match.Groups["Number"].Index;
int length = match.Groups["Number"].Length;
text = text.Remove(index, length);
text = text.Insert(index, Program.form1.textBox11.Text);
File.WriteAllText(filepath, text);
}