【问题标题】:Disconnecting without disconnecting?断开而不断开?
【发布时间】:2015-12-21 15:02:58
【问题描述】:

对于我的一些项目,我必须禁用我的连接大约 5 秒钟,然后再次启用它。

我现在该怎么做(这不是最好的解决方案,但我使用的是 Windows VPN):

  • 我设置了一个 VPN,它不会让任何互联网低谷,这让我有点断开连接,但比重新连接 Wi-Fi 更快。

所以我基本上想知道一种断开连接的方法,例如连接到损坏的 VPN(无 Wi-Fi)。

在 C# 代码中。

这可能吗?

【问题讨论】:

    标签: c#


    【解决方案1】:

    a look:

    使用 netsh 命令,您可以启用和禁用“本地连接”

      interfaceName is “Local Area Connection”.
    
      static void Enable(string interfaceName)
        {
         System.Diagnostics.ProcessStartInfo psi =
                new System.Diagnostics.ProcessStartInfo("netsh", "interface set interface \"" + interfaceName + "\" enable");
            System.Diagnostics.Process p = new System.Diagnostics.Process();
            p.StartInfo = psi;
            p.Start();
        }
    
        static void Disable(string interfaceName)
        {
            System.Diagnostics.ProcessStartInfo psi =
                new System.Diagnostics.ProcessStartInfo("netsh", "interface set interface \"" + interfaceName + "\" disable");
            System.Diagnostics.Process p = new System.Diagnostics.Process();
            p.StartInfo = psi;
            p.Start();
        }
    

    【讨论】:

    • 嗯,一定会这样的:)
    • 您的意思是“会尝试”吗?一定要做到:)
    • 是的,我试过这样:Enable("Local Area Connection");
    • 可能我错了,但该解决方案仅适用于以太网吗? i.imgur.com/dzGJ0rG.png 我不知道我有本地连接 atm
    • 我会用电缆试试这个,不能很快做那个atm,如果它可以用电缆也很好:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-12-03
    • 2018-10-04
    • 1970-01-01
    • 2012-06-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多