How to disconnect from internet using C#?

1.8k views Asked by At

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.

2

There are 2 answers

1
Brad Semrad On BEST ANSWER

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

0
Jeff Winn On

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!