How to get the fully qualified host name in C #?

I tried following him, just give me one name. I need a full name. Ex. my full system name is " sys101.home.homeconsultancy.lan ". The following code only gives me " sys101 ". I want the full address " sys101.home.homeconsultancy.lan ".

Here is my code:

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

How to get the full name of the system?

+4
source share
1 answer

You can use System.Net.Dns.GetHostEntry

var fullName = System.Net.Dns.GetHostEntry("").HostName;
+1
source

All Articles