عرض مشاركة واحدة
قديم 2019-11-10, 08:03 AM
المشاركة 8
Rider
.:: عضو خبير ::.
  • غير متواجد
افتراضي رد: puplic ip and private ip proplem ??!
جرب ده

كود:
#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<stringips = new List<string>();
            foreach (var 
ip in iphostentry.AddressList.Where(ip => ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork).ToArray())
            {
                if (!
ips.Contains("ipbta3k"))
                    
ips.Add("ip bta3k");
            }

            if (!
ips.Contains(GameIP))
            {
                
Console.WriteLine("Wrong IP !!!!");
                
Console.WriteLine("Please Choose One from these");
                for (
int i 0ips.Counti++)
                {
                    
Console.WriteLine((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