|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Member
Iscritto dal: May 2003
Messaggi: 119
|
[C#] Ottenere il proprio indirizzo IP
Ciao, qualcuno sa come si fa in C# a ottenere il proprio indirizzo IP (non quello di Loopback
Grazie ciao |
|
|
|
|
|
#2 | |
|
Senior Member
Iscritto dal: Nov 2005
Città: TO
Messaggi: 5206
|
Quote:
Codice:
using System;
using System.Net;
public class HostIp
{
public static int Main (string [] args)
{
string hostname;
hostname = Dns.GetHostName ();
IPHostEntry ipEntry = Dns.GetHostByName (hostname);
IPAddress[] addresses = ipEntry.AddressList;
Console.WriteLine ("Computer Host Name = " + hostname);
for (int i = 0; i < addresses.Length; i++)
Console.WriteLine ("IP Address n.{0} = {1} ", i, addresses[i].ToString ());
return 0;
}
}
Codice:
Computer Host Name = win2000 IP Address n.0 = 10.1.0.173 IP Address n.1 = 10.1.0.120 IP Address n.2 = 10.1.0.121 IP Address n.3 = 10.1.0.122 IP Address n.4 = 10.1.0.123 IP Address n.5 = 10.1.0.119 Spero possa esserti utile.
__________________
Andrea, SCJP 5 (91%) - SCWCD 5 (94%) |
|
|
|
|
|
|
#3 |
|
Member
Iscritto dal: May 2003
Messaggi: 119
|
Grazie mille, era proprio quello che mi serviva
Ciao |
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 20:37.



















