How to get full host name in C#?

本小妞迷上赌 提交于 2019-12-10 17:05:28

问题


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?


回答1:


You can use System.Net.Dns.GetHostEntry

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


来源:https://stackoverflow.com/questions/37087949/how-to-get-full-host-name-in-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!