如您所见,代码是找到一个值并将其替换,但是我希望能够从同一文件中找到其他5个类似的模式,这是构建ini文件的方式有点复杂。任何形式的“线索”或帮助都会有所帮助。到目前为止,我设法更改了最后一个 DeadZone = 0.1和第一个DeadZone = 0.1,但是当我选择输入值时,我希望它同时覆盖所有这6个。/初学者这是TAInput.ini[TAGame.PlayerInput_TA]MouseSensitivity=10TapTime=0.5DoubleTapTime=0.25GamepadDeadzone=0.1 // <-- Should not be captured either but haven't been so far.GamepadLookScale=20KeyboardAxisBlendTime=0GamepadDeadzones=( Type=IPT_360, Key=XboxTypeS_RightTriggerAxis, DeadZone=0.1 )GamepadDeadzones=( Type=IPT_360, Key=XboxTypeS_LeftTriggerAxis, DeadZone=0.1 )GamepadDeadzones=( Type=IPT_PS4, Key=XboxTypeS_RightTriggerAxis, DeadZone=0.1 )GamepadDeadzones=( Type=IPT_PS4, Key=XboxTypeS_LeftTriggerAxis, DeadZone=0.1 )GamepadDeadzones=( Type=IPT_XBOX_ONE, Key=XboxTypeS_RightTriggerAxis, DeadZone=0.1 )GamepadDeadzones=( Type=IPT_XBOX_ONE, Key=XboxTypeS_LeftTriggerAxis, DeadZone=0.1 )[ProjectX.ControlPreset_X]这是Form1.cs try { const string FILENAME = "TAInput.ini"; string text = File.ReadAllText(FILENAME); const string DEADZONE = @"DeadZone=0.(?<Ratio>[\d\.]+)"; Match match = Regex.Match(text, DEADZONE, RegexOptions.Multiline); if (match.Success) { int index = match.Groups["Ratio"].Index; int length = match.Groups["Ratio"].Length; text = text.Remove(index, length); text = text.Insert(index, nudInput.Value.ToString() + "" + "\n"); File.WriteAllText(FILENAME, text); Process.Start(FILENAME); } } catch { MessageBox.Show("No"); }
1 回答
- 1 回答
- 0 关注
- 134 浏览
添加回答
举报
0/150
提交
取消