private void GetServerIp() { try { var iplist = ProxyServer.GetHostIp(); IPAddress ipshow; if (iplist.Count() == 0) { tb_Log.Text = "IP地址获取失败!"; } var port = AppConfig.Instance().Port.ToString(); tb_Log.Text += "\n获取IP地址开始:"; foreach (var ip in iplist) { tb_Log.Text += "\nIP:" + ip; } tb_Log.Text += "\n请点击 下一步 继续。"; } catch (Exception ex) { tb_Log.Text += "\n获取本机IP地址时出错!\n错误信息:" + ex.Message; } }
private void GetServerIp() { try { var iplist = ProxyServer.GetHostIp(); IPAddress ipshow; cb_ip.Items.Clear(); cb_ip.Items.AddRange(iplist); cb_ip.Text = (!string.IsNullOrEmpty(AppConfig.Instance().Ip) && IPAddress.TryParse(AppConfig.Instance().Ip, out ipshow) && iplist.Contains(ipshow) ? AppConfig.Instance().Ip : cb_ip.Items[0].ToString()); tb_port.Text = AppConfig.Instance().Port.ToString(); } catch { cb_ip.SelectedText = String.Empty; tb_port.Text = AppConfig.Instance().Port.ToString(); } }