Enviroment.MachineName returns short name:
public static string GetCurrentMachineName()
{
return GetMachineName(Environment.MachineName); //returns hostname
}
I have short hostname: shortName
and fullname: shortName.company.local
.
So, when i call GetCurrentMachineName()
i get only shortName
instead 'shortName.company.local'.
What can be wrong?
P.S.:
It is not work for me: for example, my hostname is hostname1
.
And my friend at current network has hostname named hostname2
. So, when i execute this code:
return System.Net.Dns.GetHostEntry("").HostName;
with hostname2 it resolve to hostname2.company.local
and hostname1
to my hostname.
I solve ,my problem:
Flush DNS cache
ipconfig /flushdns
Clear my hosts
file.
Thank you for help!