Wednesday, July 16, 2008

Get IP address in Windows MObile

Hi Guys,

Get IP address of the device, when they connected to network.

private void GetMyIP()
{
IPHostEntry hostentry = Dns.GetHostEntry(Dns.GetHostName());
if (hostentry != null)
{
IPAddress[] collectionOfIPs = hostentry.AddressList;
MessageBox.Show(collectionOfIPs[0].ToString());
}
}

Thank you

3 comments:

  1. hi!! what references do you use for IPHostEntry , dns and IPAdress.

    this is one of the errors.
    "The type or namespace name 'IPHostEntry' could not be found (are you missing a using directive or an assembly reference?)"


    thank you

    ReplyDelete
  2. you have to add the namespace System.Net to your "using" list.

    ReplyDelete
  3. thanks my man, your article realy helpfull for me

    ReplyDelete