This can also be done in the .Net 2.0 library in the System.Net.NetworkInformation Namespace
The idea is to get the network card on the computer and then check its properties, namely IP address. Remember that a computer can have more than network card and each are using a different IP address, so this method allows identification of the different IP addresses.
Code:
NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();
Use System.Net.NetworkInformation.GetAllNetworkInterfaces()
to get all
System.Net.NetworkInformation.NetworkInterface
then from
Code:
adapters[0]; //read how to get the ip stats used
get the IP address from some property on the card.
I remember using the same code above vaguely when I used .net 2.0 beta more that a year ago.
If you are using .net 2.0 now then read up in these classes. I recall this to work nicely but I lost my original snippet.
I remember someone here did a code that showed this too. It may have been the winsock class or some other class, but it showed up the ip just like the ip in the display of network properties.
The ip address that is used as a gateway. I am not sure how to get that at this time. You ever noticed a site which gives you your ip address but the address is not correct but you think it is the address of your router or something?
Let's act on what we agree on now, and argue later on what we don't.
Black men leave Barbeque alone if Barbeque don't trouble you