Is there a way to programmatically and temporarily disconnect network connectivity in .NET 4.0?
I know I can get the current network connectivity status by doing this…
System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()
but for testing purposes I would like test my application’s behavior when it loses network connectivity (without physically unplugging the network cable).
Thanks,
Chris.
You could do it with WMI. Here’s one we use for disabling the physical adapter to test these types of scenarios.
You didn’t indicate the OS, but this works in Windows 7 and Windows 8.
Note that you will need to be an administrator for this to function.