0
ipconfig/allからこのsnippitから代替DNSサーバを抽出しようとしています。基本的に、私はDNS Servers
ラインとNetBIOS over Tcpip
ラインIP設定から代替DNSサーバを解析する
Ethernet adapter Local Area Connection 2:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Realtek PCIe GBE Family Controller #2
Physical Address. . . . . . . . . : 00-0B-AB-37-2D-28
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . : fe80::edd5:2e2e:6979:5b59%3(Preferred)
Autoconfiguration IPv4 Address. . : 169.254.91.89(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.0.0
Default Gateway . . . . . . . . . :
DHCPv6 IAID . . . . . . . . . . . : 67111851
DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-18-B0-7D-38-00-0B-AB-2E-90-1E
DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
fec0:0:0:ffff::2%1
fec0:0:0:ffff::3%1
NetBIOS over Tcpip. . . . . . . . : Enabled
ここでは、プライマリDNSサーバーを取得するための私のコードだとの間のすべての行を書きたいです。
string[] lines = System.IO.File.ReadAllLines(@"C:\Temp\ipconfig.txt");
foreach (string line in lines)
{
if (line.Contains("DNS Servers")
{
txtPreferredDNS = line.Split(':').First();
}
// need help getting the alternate DNS servers
}
これを試している理由はありますか?あなたは[C#コードでそれらを手に入れることができます](https://stackoverflow.com/questions/2906706/how-do-i-get-my-current-dns-server-in-c)。 – nvoigt