Dudipoli
Dudipoli

Reputation: 471

Get IP from computer name in intranet C# Windows application

I'm trying to get an IP address from computer name in same network... Something like CMD command "nbtstat -a COMPNAME" in C# windows application

Upvotes: 3

Views: 6954

Answers (2)

horgh
horgh

Reputation: 18563

Use Dns.GetHostAddresses:

Dns.GetHostAddresses("some pc name")
   .ToList()
   .ForEach(a => Console.WriteLine(a.ToString()));

Upvotes: 12

Raptor
Raptor

Reputation: 54268

Try this method:

Dns.GetHostName();

http://msdn.microsoft.com/en-us/library/system.net.dns.gethostname.aspx

Upvotes: -1

Related Questions