using System;
using System.Diagnostics;
namespace ZZ
{
class ZZConsole
{
[STAThread]
static void Main(string[] args)
{
string ip = "192.192.132.229";
string strRst = CmdPing(ip);
Console.WriteLine(strRst);
Console.ReadLine();
}
private static string CmdPing(string strIp)
{
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError
c#调用ping网络连接检查
最新推荐文章于 2024-08-14 16:54:24 发布
本文展示了如何使用C#调用Ping命令来检查网络连接。通过创建Process对象并设置相关参数,执行命令行操作,然后根据输出结果判断网络连接状态,如‘连接’、‘无法到达目的主机’、‘超时’或‘无法解析主机’。
摘要由CSDN通过智能技术生成