#region Check IP // Get host name String strHostName = System.Net.Dns.GetHostName(); // Find host by name System.Net.IPHostEntry iphostentry = System.Net.Dns.GetHostEntry(strHostName); // Enumerate IP addresses List<string> ips = new List<string>(); foreach (var ip in iphostentry.AddressList.Where(ip => ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork).ToArray()) { if (!ips.Contains(ip.ToString())) ips.Add(ip.ToString()); } if (!ips.Contains(GameIP)) { Console.WriteLine("Wrong IP !!!!"); Console.WriteLine("Please Choose One from these"); for (int i = 0; i < ips.Count; i++) { Console.WriteLine((i + 1) + ". " + ips[i]); } var read = System.Console.ReadKey(); int no = 0; if (int.TryParse(read.KeyChar.ToString(), out no)) { if (no <= ips.Count) { GameIP = ips[no - 1]; IniFile.Write("configuration", "IP", GameIP); } } } #endregion Check IP