Ref : codeproject.com
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Management;
using System.Collections;
public class ....
{
// Get local IP
public static string GetIP()
{
string ip = "";
string strHostName = GetHostName();
//IPHostEntry ipEntry = Dns.GetHostByName(strHostName);
IPHostEntry ipEntry = Dns.GetHostEntry(strHostName);
IPAddress[] addr = ipEntry.AddressList;
ip = addr[0].ToString();
//MessageBox.Show(ip);
return ip;
}
// Get hostname
public static string GetHostName()
{
return Dns.GetHostName();
}
}
No comments:
Post a Comment