C# snaps

C# 启用 禁用 本地连接

 1         static void Enable(string interfaceName)
 2         {
 3             System.Diagnostics.ProcessStartInfo psi =
 4                    new System.Diagnostics.ProcessStartInfo("netsh", "interface set interface "" + interfaceName + "" enable");
 5             System.Diagnostics.Process p = new System.Diagnostics.Process();
 6             p.StartInfo = psi;
 7             p.Start();
 8         }
 9 
10         static void Disable(string interfaceName)
11         {
12             System.Diagnostics.ProcessStartInfo psi =
13                 new System.Diagnostics.ProcessStartInfo("netsh", "interface set interface "" + interfaceName + "" disable");
14             System.Diagnostics.Process p = new System.Diagnostics.Process();
15             p.StartInfo = psi;
16             p.Start();
17         }
18         static List<Task> list = new List<Task>();
19         public static void Main(string[] str)
20         {
21             Disable("本地连接");
22             Console.ReadKey();
23             Enable("本地连接");
24         }
C# 启用禁用本地连接
原文地址:https://www.cnblogs.com/netact/p/4627682.html