Hello,
can anybody help me with code snippet to get active network card name, that is the network card currently connected to the internet in c# or vb.net?
thanks
Printable View
Hello,
can anybody help me with code snippet to get active network card name, that is the network card currently connected to the internet in c# or vb.net?
thanks
Not sure if this helps:
Look for functions under System.Net and/or System.Net.Dns for some network information.Code:Public Shared ReadOnly Property CurrentIPs() As String()
Get
Dim ips As New List(Of String)
Dim addresses() As Net.IPAddress = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName).AddressList
For i As Integer = addresses.Count / 2 To addresses.Count - 1
ips.Add(addresses(i).ToString)
Next
Return ips.ToArray
End Get
End Property
thanks, but this is getting ip addresses instead
This thread sounds largely what you are asking. The catch is it will retrieve the names, but not select the "active" one as you mention.
http://www.vbforums.com/showthread.php?t=653237
no you are getting me wrong, am trying to get the name of the currently active network card connected to internet, there might be more than one card in the system
Okay, then spend a bit more time in the search feature of the forums. This does contain the actual adapter names, but you will have to do a little weed-wacking to get it exactly how you want.
http://www.vbforums.com/showthread.p...dapter+network