static public void GetNetworkAdress() { IPGlobalProperties computerProperties = IPGlobalProperties.GetIPGlobalProperties(); NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces(); List <NetworkAdapter> adapterList = new List <NetworkAdapter>(); int i = 0; foreach (NetworkInterface adapter in nics) { //if(adapter.GetIPv4Statistics().UnicastPacketsReceived + adapter.GetIPv4Statistics().NonUnicastPacketsReceived == 0) // continue; NetworkAdapter adaptertje = new NetworkAdapter(); PhysicalAddress address = adapter.GetPhysicalAddress(); // name of the adapter adaptertje.adapterName = StringFunction.FilterString(adapter.Description); adaptertje.adapterAltName = adapter.Name; // IPv4 and IPv6 adresses and MTU if (adapter.GetIPProperties().GatewayAddresses.Count > 0) { adaptertje.gateway = adapter.GetIPProperties().GatewayAddresses[0].Address.ToString(); } foreach (UnicastIPAddressInformation ip in adapter.GetIPProperties().UnicastAddresses) { if (ip.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) { adaptertje.IPv4Adress = ip.Address.ToString(); adaptertje.MTU = (Mathf.Floor(adapter.GetIPProperties().GetIPv4Properties().Mtu / 100f) / 10f) + " KB"; } else if (ip.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6) { adaptertje.IPv6Adress = ip.Address.ToString(); adaptertje.MTU = (Mathf.Floor(adapter.GetIPProperties().GetIPv6Properties().Mtu / 100f) / 10f) + " KB"; } } // Adapter nominal speed if (adapter.Speed == 1000000000) { adaptertje.nominalSpeed = "Gigabit"; } else if (adapter.Speed > 1000000000) { adaptertje.nominalSpeed = (Mathf.Ceil((float)adapter.Speed / 100000000) / 10f) + " Gigabit"; } else if (adapter.Speed < 1000000) { adaptertje.nominalSpeed = (Mathf.Floor((float)adapter.Speed / 100f) / 10f) + " Kbps"; } else { adaptertje.nominalSpeed = (Mathf.Floor((float)adapter.Speed / 100000f) / 10f) + " Mbps"; } // MAC address byte[] bytes = address.GetAddressBytes(); string mac = null; for (i = 0; i < bytes.Length; i++) { mac = string.Concat(mac + (string.Format("{0}", bytes[i].ToString("X2")))); if (i != bytes.Length - 1) { mac = string.Concat(mac + "-"); } } adaptertje.macAdress = mac; adapterList.Add(adaptertje); } if (netAdapters.Length != adapterList.Count) { netAdapters = new NetworkAdapter[adapterList.Count]; } i = 0; foreach (NetworkAdapter adapter in adapterList) { netAdapters[i] = adapter; i++; } }