Get Wireless IP Address List - CSharp Network

CSharp examples for Network:IP Address

Description

Get Wireless IP Address List

Demo Code

// All Rights Reserved , Copyright (C) 2012 , Hairihan TECH, Ltd. 
using System.Net.NetworkInformation;
using System.Net;
using System.Management;
using System.Collections.Generic;

public class Main{

        public static List<string> GetWirelessIPAddressList()
        {//from w  w w . j  ava  2  s.  c  o  m
            List<string> ipAddressList = new List<string>();
            NetworkInterface[] networkInterfaces = NetworkInterface.GetAllNetworkInterfaces();
            foreach (NetworkInterface ni in networkInterfaces)
            {
                if (ni.Description.Contains("Wireless"))
                {
                    foreach (UnicastIPAddressInformation ip in ni.GetIPProperties().UnicastAddresses)
                    {
                        if (ip.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                        {
                            ipAddressList.Add(ip.Address.ToString());

                        }
                    }
                }
            }
            return ipAddressList;
        }
}

Related Tutorials