4

how to get network connection list in my computer with c# vpn list or other

in windows 7 this path Control Panel\Network and Internet\Network Connections

i need for write a function to connect to internet in c#

John Saunders
  • 160,644
  • 26
  • 247
  • 397
jozi
  • 2,833
  • 6
  • 28
  • 41
  • 1
    Are you looking for network interfaces, VPNs, TCP sessions, connected shares, or something else? – Gabe Apr 05 '10 at 04:05

1 Answers1

6

I assume you're looking for the list of network interfaces.

The System.Net.NetworkInformation.NetworkInterface class is probably what you are after, specifically the GetAllNetworkInterfaces() method.

To get the same list as Control Panel, I suspect you will also need to filter on the NetworkInterfaceType property value, to skip loopback and tunneling interfaces.

Leon Breedt
  • 1,196
  • 8
  • 13
  • i need to get active and deactivate connection list but in you answer only active connection showed – jozi Apr 05 '10 at 05:50
  • 1
    I don't believe you can do this using the .NET APIs, you will probably need to use P/Invoke. If you need this for programmatically enabling/disabling a particular interface, there is this existing question: http://stackoverflow.com/questions/860673/programatically-disable-enable-network-interface – Leon Breedt Apr 05 '10 at 05:57
  • no this link for disable card but i looking for connect to internet – jozi Apr 05 '10 at 05:59