So for fun, I decided to write a tool that loads a game's ini file(Outlast) and then lets you change the values for certain things.
The way I did this was, in the original ini, I found the line number the variable was on, and then removed the variable name in the code leaving only the value it held, and it wrote that to the textbox.
I am horrible at explaining things, so to clarify, in this particular ini file this is what line 42 is:
NormalWalkSpeed=200,
And in the code, I did this to write that number to a textbox:
WalkSpeedTxtBox.Text = GameLocation.DefaultGameIniLines[42].Replace("NormalWalkSpeed=", "");
And to change it, this is the button's code:
GameLocation.DefaultGameIniLines[42] = "NormalWalkSpeed=" + walkspeed;
System.IO.File.WriteAllLines(GameLocation.DefaultGameIniLocation, GameLocation.DefaultGameIniLines);
MessageBox.Show("Success! Walk speed has been set to " + WalkSpeedTxtBox.Text);
System.Media.SystemSounds.Beep.Play();
So the problem right off the bat with this is, obviously, if the ini file is not exactly the same as it was before, as in the lines change, this will no longer work and I'd have to rewrite everything.
What exactly would be a better way of doing what I want to do?