C# 网络连接判断(2)

2020-12-22 09:33

Corp./r/n/r/nD://himuraz//csharpproject//ZZ//ConsoleTest//bin//Debug>ping -n 1

192.192.132.231/r/n/r/r/nPinging 192.192.132.231 with 32 bytes of data:/r/r/n/r/r/nReply from 192.192.132.231: bytes=32 time<10ms TTL=128/r/r/n/r/r/nPing statistics for

192.192.132.231:/r/r/n Packets: Sent = 1, Received = 1, Lost = 0 (0%

loss),/r/r/nApproximate round trip times in milli-seconds:/r/r/n Minimum = 0ms, Maximum = 0ms, Average =

0ms/r/r/n/r/nD://himuraz//csharpproject//ZZ//ConsoleTest//bin//Debug>exit/r/n"

有了输出结果,那还有什么好说的,分析strRst字符串就可以知道网络的连接情况了。

下面是一个完整的程序,当然对Ping.exe程序执行的结果不全,读者可以进一步修改, 完整代码如下:

view plaincopy to clipboardprint? 1. using System;

2. using System.Diagnostics;

3. namespace ZZ

4. {

5. class ZZConsole

6. {

7. [STAThread]

8. static void Main(string[] args)

9. {

10. string ip = "192.192.132.229";

11. string strRst = CmdPing(ip);

12. Console.WriteLine(strRst);

13. Console.ReadLine();

14. }

15. private static string CmdPing(string strIp)

16. {

17. Process p = new Process();

18. p.StartInfo.FileName = "cmd.exe";

19. http://www.77cn.com.cneShellExecute = false;

20. p.StartInfo.RedirectStandardInput = true;


C# 网络连接判断(2).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:酸碱滴定习题答案

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: