5

I have tried by following by it just give me single name. I want full name. Ex. my system full name is "sys101.home.homeconsultancy.lan". Following code gives me just "sys101". I want full address "sys101.home.homeconsultancy.lan".

Here is my code:

string hostName = System.Net.Dns.GetHostName();

How can I get full system name?

jww
  • 97,681
  • 90
  • 411
  • 885
Nanji Mange
  • 2,155
  • 4
  • 29
  • 63

1 Answers1

4

You can use System.Net.Dns.GetHostEntry:

var fullName = System.Net.Dns.GetHostEntry(string.Empty).HostName;

If an empty string is passed as the hostNameOrAddress argument, then this method returns the IPv4 and IPv6 addresses of the local host.

Ian Kemp
  • 28,293
  • 19
  • 112
  • 138
Hamid Pourjam
  • 20,441
  • 9
  • 58
  • 74