I’m working on a C# application. I need to know when the application connects to a different Wi-Fi network. The tricky part here is that the application is assigned the same IP address on both Wi-Fi networks:
- The application is currently connected to Wi-Fi #1 with IP address 11.22.33.44.
- On the PC where the application runs, I disconnect the PC from Wi-Fi #1.
- The PC quickly connects to Wi-Fi #2 and is assigned the same IP address (in this example 11.22.33.44).
- The application receives the NetworkChange.NetworkAddressChanged event.
- The application loops in the network interfaces returned by NetworkInterface.GetAllNetworkInterfaces() in order to detect an IP address change (by checking if the IP address, assigned to a particular NetworkInterface.Id, has changed).
- The problem is that the network interface information has not changed (NetworkInterface.OperationalStatus is still UP and the IP address is the same).
- The NetworkChange.NetworkAvailabilityChanged event is not received. If the NetworkInterface.OperationalStatus was to DOWN and then back to UP, I could detect a change.
Any idea?
Is it possible to access the list of Wi-Fi network and find out which one the application is connected with?
Thanks!