private void GetServerConfig() { if (!iniConfig.ExistINIFile(ConfigPath))//不存在 { iniConfig.CreateIniFile(ConfigPath, "127.0.0.1", 11000); this.ServerAddress = IPAddress.Parse("127.0.0.1"); this.ServerPort = 11000; } else { try { this.ServerAddress = IPAddress.Parse(iniConfig.IniReadValue("Server", "IPAddress", ConfigPath)); } catch { if (MessageBox.Show("IP地址格式不正确,请重新输入") == DialogResult.OK) { Setting.ShowForm(); } } try { this.ServerPort = int.Parse(iniConfig.IniReadValue("Server", "Port", ConfigPath)); } catch { if (MessageBox.Show("端口地址格式不正确,请重新输入") == DialogResult.OK) { Setting.ShowForm(); } } } }
private void Setting_Load(object sender, EventArgs e) { try { this.IPAddresstxt.Text = iniConfig.IniReadValue("Server", "IPAddress", inipath); this.centerableTextBox1.SetText(iniConfig.IniReadValue("Server", "Port", inipath)); } catch { } }