How to disconnect from internet using C#?

只愿长相守 提交于 2019-12-12 03:22:52

问题


I have a RAS connection and I need disconnect to it using C#. How I do this? Currently I'm using dotRas library to handling ras connections.


回答1:


Based on this documentation you should just call the RasHangUp function.




回答2:


Using the DotRas SDK, you'd just need to get the RasConnection instance you want and call HangUp().

using System.Linq;
using DotRas;

RasConnection conn = RasConnection.GetActiveConnections().Where(o => o.EntryName == "My Entry").FirstOrDefault();
if (conn != null)
{
    conn.HangUp();
}

Hope that helps!



来源:https://stackoverflow.com/questions/8841991/how-to-disconnect-from-internet-using-c

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!