c#判断是否有网络
//调用操作系统API [System.Runtime.InteropServices.DllImport("wininet")] private extern static bool InternetGetConnectedState(out int connectionDescription, int reservedValue); /// <summary> /// 判断是否链接到外网 /// </summary> public static bool IsNetWorkConnect() { int i = 0; return InternetGetConnectedState(out i, 0) ? true : false; }