如何从C#获取所有可用互联网连接的列表? [英] How can I get list of all available internet connections from C#?

查看:77
本文介绍了如何从C#获取所有可用互联网连接的列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我被困在一个地方..是他们可以获得用户系统上所有可用互联网连接列表的任何方式.. 。?



简单来说:我需要所有可用ISP的列表(在他的系统上可用),以显示用户连接一个。



例如:用户安装了两个ISP连接

1.AOL和

2.AT&T互联网服务

现在用户将选择我必须连接到所选ISP的任何一个连接。



-With问候,

AJ

Hi,

I am stuck at a place.. is their any way that I can get list of all the available internet connections on the users system...?

In simple words: I need list of all available ISP(available on his system) to show the user to connect one.

E.g.: User has two ISP connections installed
1. "AOL" and
2. "AT&T Internet Services"
Now user will select any one connection i have to connect to that selected ISP.

-With Regards,
AJ

推荐答案

我假设您正在寻找网络接口列表。它可以通过System.Net.NetworkInformation.NetworkInterface类,特别是GetAllNetworkInterfaces()方法。以下是示例代码



I assume you're looking for the list of network interfaces. It is possible through System.Net.NetworkInformation.NetworkInterface class, specifically the GetAllNetworkInterfaces() method. Here is the sample code

public static void DisplayDnsConfiguration()
{
    NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();
    foreach (NetworkInterface adapter in adapters)
    {
        IPInterfaceProperties properties = adapter.GetIPProperties();
        Console.WriteLine(adapter.Description);
        Console.WriteLine("  DNS suffix .............................. : {0}",
            properties.DnsSuffix);
        Console.WriteLine("  DNS enabled ............................. : {0}",
            properties.IsDnsEnabled);
        Console.WriteLine("  Dynamically configured DNS .............. : {0}",
            properties.IsDynamicDnsEnabled);
    }
    Console.WriteLine();
}


这篇关于如何从C#获取所有可用互联网连接的列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆