G
Guest
Hello,
I get my IP Address(es) by looping through
NetworkInterface.GetAllNetworkInterfaces() and
adapter.GetIPProperties().UnicastAddresses
This works fine! (see code snippet at the end)
But what, if one or all of the IP Address(es) will change? (By the User or
through DHCP etc.)
How can I detect this?
Is there something like an IPAddressChanged Event in the framework?
---code snippet ---
NetworkInterface[] adapters =
NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface adapter in adapters)
{
Console.WriteLine(adapter.Name);
IPInterfaceProperties adapterProperties =
adapter.GetIPProperties();
UnicastIPAddressInformationCollection uniCast =
adapterProperties.UnicastAddresses;
if (uniCast != null)
{
foreach (UnicastIPAddressInformation uni in uniCast)
{
Console.WriteLine(" IP Address : {0}", uni.Address);
}
Console.WriteLine();
}
}
I get my IP Address(es) by looping through
NetworkInterface.GetAllNetworkInterfaces() and
adapter.GetIPProperties().UnicastAddresses
This works fine! (see code snippet at the end)
But what, if one or all of the IP Address(es) will change? (By the User or
through DHCP etc.)
How can I detect this?
Is there something like an IPAddressChanged Event in the framework?
---code snippet ---
NetworkInterface[] adapters =
NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface adapter in adapters)
{
Console.WriteLine(adapter.Name);
IPInterfaceProperties adapterProperties =
adapter.GetIPProperties();
UnicastIPAddressInformationCollection uniCast =
adapterProperties.UnicastAddresses;
if (uniCast != null)
{
foreach (UnicastIPAddressInformation uni in uniCast)
{
Console.WriteLine(" IP Address : {0}", uni.Address);
}
Console.WriteLine();
}
}