How to get client IP Address / How to get machine IP Address.
public string getclientIP()
{
ManagementObjectSearcher objSearcher = new ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = 'TRUE'");
ManagementObjectCollection objCollection = objSearcher.Get();
string Ip = "";
foreach (ManagementObject obj in objCollection)
{
string[] AddressList = (string[])obj["IPAddress"];
foreach (string Address in AddressList)
{
Ip=Address;
break;
}
}
return Ip;
}
public string getclientIP()
{
ManagementObjectSearcher objSearcher = new ManagementObjectSearcher("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = 'TRUE'");
ManagementObjectCollection objCollection = objSearcher.Get();
string Ip = "";
foreach (ManagementObject obj in objCollection)
{
string[] AddressList = (string[])obj["IPAddress"];
foreach (string Address in AddressList)
{
Ip=Address;
break;
}
}
return Ip;
}