Ping.exe问题,ping IP问题 [英] Problem with Ping.exe,problem in ping an IP

查看:114
本文介绍了Ping.exe问题,ping IP问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 使用系统; 
使用 System.Collections.Generic;
使用 System.ComponentModel;
使用 System.Data;
使用 System.Drawing;
使用 System.Linq;
使用 System.Text;
使用 System.Windows.Forms;
使用 System.Diagnostics;
使用 System.Net.NetworkInformation;
使用 System.Web;
使用 System.Net;



命名空间 WindowsFormsApplication6
{
public partial class Form1:Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click( object sender,EventArgs e)
{


Process.Start( ping 192 168 42 145 );



}
}
}









我点击按钮ping窗口后立即打开和关闭这个代码...请帮助我....提前感谢....

解决方案

启动一个单独的进程完全没有意义,特别是对于ping。你好吗?要与这个过程互动吗? - 亲cesses是孤立的。



而是在你自己的进程中使用类 System.Net.NetworkInformation.Ping

http://msdn.microsoft.com/ en-us / library / system.net.networkinformation.ping.aspx [ ^ ]。



祝你好运,

-SA

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Net.NetworkInformation;
using System.Web;
using System.Net;



namespace WindowsFormsApplication6
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
          
           
            Process.Start("ping",192.168.42.145");
            
         

        }
    }
}





I m usng this code bt as soon as i click on button ping window get open and closed ...pls help me....thanks in advance....

解决方案

It makes absolutely no sense to start a separate process, especially just for ping. How are you going to interact with this process? — the processes are isolated.

Instead, use the class System.Net.NetworkInformation.Ping in your own process:
http://msdn.microsoft.com/en-us/library/system.net.networkinformation.ping.aspx[^].

Good luck,
—SA


这篇关于Ping.exe问题,ping IP问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆