I tried every trick in the book, creating a new object, instantiating it (even tho it says i can't) and just trying to create a reference to use it, and then also trying to call the .Address value inside it while using it like i would use a shared member (without instantiation) and nothing is working, msdn sample/help is useless... i even tried inheriting it and useing it like that, none of them worked, i am sure i am missing something, can anyone give me some code samples? here is the msdn docs on it to to give you an overview...
http://msdn.microsoft.com/en-us/library/system.net.networkinformation.gatewayipaddressinformation.aspx
although i like vb.net more i can read and coded in both c# and vb.net so either will be fine.
thanks:)
an aside: if anyone is wondering why, im just trying to get my routers name/label from a pc as shown here... How to get Router Name & IP as shown in Windows Network Tab? (in Code)
From MSDN:
NetworkInterface.GetAllNetworkInterfaces()
to get a set of adapters.adapter.GetIPProperties().GatewayAddresses
.GatewayAddresses
is a GatewayIPAddressInformation
.public static void DisplayGatewayAddresses()
{
Console.WriteLine("Gateways");
NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface adapter in adapters)
{
IPInterfaceProperties adapterProperties = adapter.GetIPProperties();
GatewayIPAddressInformationCollection addresses = adapterProperties.GatewayAddresses;
if (addresses.Count >0)
{
Console.WriteLine(adapter.Description);
foreach (GatewayIPAddressInformation address in addresses)
{
Console.WriteLine(" Gateway Address ......................... : {0}",
address.Address.ToString());
}
Console.WriteLine();
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With