記憶盒子

把記憶裝進(jìn)灰色的盒子,封裝起來,那年那月,重新拾起。

首頁搜索目錄
search
當(dāng)前主題: 軟件編程

asp.net(c#)中實(shí)現(xiàn)ping功能

作者:Kaka    時(shí)間:2009-9-7 3:41:46    瀏覽:    評(píng)論:1

      在asp.net(c#)下實(shí)現(xiàn)ping功能

      添加引用:

using System.Diagnostics;

      程序代碼:

   string hostname = "http://www.baidu.com";
   
   Process prc=new Process();  
   prc.StartInfo.FileName="cmd.exe";  
   prc.StartInfo.UseShellExecute=false;  
   prc.StartInfo.RedirectStandardInput   =   true;  
   prc.StartInfo.RedirectStandardOutput   =   true;  
   prc.StartInfo.RedirectStandardError   =   true;  
   prc.StartInfo.CreateNoWindow   =   false;  
   prc.Start();  
   prc.StandardInput.WriteLine("ping " + hostname);  
   prc.StandardInput.Close();  
   Response.Write(prc.StandardOutput.ReadToEnd());

       執(zhí)行結(jié)果:

Microsoft Windows 2000 [Version 5.00.2195] (C) 版權(quán)所有 1985-2000 Microsoft Corp. C:\WINNT\system32>ping http://www.baidu.com Pinging http://www.baidu.com [59.37.71.86] with 32 bytes of data: Reply from 59.37.71.86: bytes=32 time=11ms TTL=59 Reply from 59.37.71.86: bytes=32 time=11ms TTL=59 Reply from 59.37.71.86: bytes=32 time=11ms TTL=59 Reply from 59.37.71.86: bytes=32 time=12ms TTL=59 Ping statistics for 59.37.71.86: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 11ms, Maximum = 12ms, Average = 11ms C:\WINNT\system32>

 

原創(chuàng)文章轉(zhuǎn)載請(qǐng)注明:文章轉(zhuǎn)載自 記憶盒子 [http://www.howtostagehomes.com/blog/]
本文地址:
http://www.howtostagehomes.com/blog/archives/aspnet-csharp-execute-ping.html

 

x

標(biāo)簽: Asp.net  

※ 網(wǎng)站速度慢?試試網(wǎng)站自動(dòng)優(yōu)化工具 ※

上一篇: asp執(zhí)行ping命令
下一篇: 外部連接對(duì)網(wǎng)站Alexa排名的重要性
  • 1.j*****
  • 高級(jí)的,對(duì)于.net c#完全看不懂
    Liwen 于 2009-9-7 9:23:21 回復(fù)
    博客是個(gè)資料庫,把一些東西記錄下來,以便需要時(shí)查找.
  • 2009/9/7 8:31:00 回復(fù)該留言

發(fā)表評(píng)論:

◎歡迎參與討論,請(qǐng)?jiān)谶@里發(fā)表您的看法、交流您的觀點(diǎn)。

訂閱博客                   QQ交流群(312716741)

  • 通過Google訂閱本站 通過鮮果訂閱本站 通過抓蝦訂閱本站
  • 通過QQ郵箱訂閱本站 通過Yahoo訂閱本站 通過有道訂閱本站

Search

最新評(píng)論及回復(fù)

最近留言

網(wǎng)站分類

Powered By Z-Blog 1.8 Walle Build 91204 Designed by Han'space

Copyright @2009-2024 All Rights Reserved. 粵ICP備14028160號(hào)-1

Powered By Z-Blog 1.8 Walle Build 91204
Copyright @2009-2024 All Rights Reserved.