How can I programmatically connect to a VPN?
问题 I have a VPN connection that I keep losing, that I need to connect to our DB server, but every second or third connection fails because I have lost the VPN connection. I'd like to add somde code - for DEBUG config only - to check the VPN connection and reconnect if necessary, before proceeding to attempt the database connection. 回答1: You could use System.Net.NetworkInformation.Ping to check if the connection is up - then rasdial to reconnect the vpn if the connection is lost. eg System