I'm writing a program in C# that needs to monitor the amount of internet bandwidth currently in use so it can do a background upload when the internet usage is low. How can I automatically determine which network adapter is the one connected to the internet?
+1
A:
You can use WMI to query all the adapters and see which one is connected.
This article shows you how to do it in VB.Net (very easily transferable to C#).
Traveling Tech Guy
2010-01-31 19:35:27
+1
A:
I ended up following a link to MSDN when I was reading this page where I found the GetBestInterface function. I was able to use that to find the adapter thats connected to the internet
Telanor
2010-01-31 20:59:09
A:
Examine the routing table and look for the interfaces that have a default route (a route to 0.0.0.0
) - that's your interface(s) that are connected to the wider world (if any).
caf
2010-02-01 00:14:10