Get and Set the IP address in C#?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

H

Does anyone know how to Get and Set the IP address in C#?

What I want to archive is to read my IP address, compare the address based on some predefine rules, and if needed, change the address (and reboot)

J
 
Try using the following:

using System.Net;

string myHostName = Dns.GetHostName().ToString();
string ipAddress = Dns.Resolve(HostName).AddressList[0].ToString();


-- Gavin
 
Back
Top