没有合适的资源?快使用搜索试试~ 我知道了~
C#调用ping
3星 · 超过75%的资源 需积分: 10 6 下载量 184 浏览量
2012-11-21
16:07:46
上传
评论
收藏 11KB TXT 举报
温馨提示
试读
10页
C#动态调用ping 并获得返回结果,代码可以直接使用,粘贴即可
资源推荐
资源详情
资源评论
#region Ping功能
/// <summary>
/// 启动Ping功能
/// </summary>
/// <param name="atFaultSID">记录上次Ping之后的不通的设备SID</param>
public void StartPing(ref System.Collections.ArrayList atFaultSID)
{
this.dbManage = new DBManage(this.webServiceUrl);
//设置并启动CMD系统进程
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = true;
//process.Start();
//取得要Ping设备的所有系统
string[] ssxtList = config.GetSsxtInfos();
if (ssxtList == null)
{ return; }
//表示每个子系统所包括的设备信息
System.Data.DataTable table;
//表示所属的系统
string systemType;
//表示当前设备的IP
string ip;
/// <summary>
/// 启动Ping功能
/// </summary>
/// <param name="atFaultSID">记录上次Ping之后的不通的设备SID</param>
public void StartPing(ref System.Collections.ArrayList atFaultSID)
{
this.dbManage = new DBManage(this.webServiceUrl);
//设置并启动CMD系统进程
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = true;
//process.Start();
//取得要Ping设备的所有系统
string[] ssxtList = config.GetSsxtInfos();
if (ssxtList == null)
{ return; }
//表示每个子系统所包括的设备信息
System.Data.DataTable table;
//表示所属的系统
string systemType;
//表示当前设备的IP
string ip;
//表示Ping结果的字符串
string outStr;
for (int i = 0; i < ssxtList.Length; i++)
{
//取得所属的系统
systemType = ssxtList[i];
//取出当前系统中的设备信息
table = this.dbManage.Sql_GetEquipmentIPinfo(systemType);
if (table != null)
{
if (table.Rows.Count > 0)
{
for (int j = 0; j < table.Rows.Count; j++)
{
//取得当前IP
ip = table.Rows[j]["ip"].ToString();
//做一下基本判断
if (ip == null || ip.Length < 7)
{
continue;
}
//判断是否多IP
if (ip.Contains(",")) //说明一个SID设备对应多个IP
{
string[] curIPList = ip.Split(',');
bool ok = true;
string outStr;
for (int i = 0; i < ssxtList.Length; i++)
{
//取得所属的系统
systemType = ssxtList[i];
//取出当前系统中的设备信息
table = this.dbManage.Sql_GetEquipmentIPinfo(systemType);
if (table != null)
{
if (table.Rows.Count > 0)
{
for (int j = 0; j < table.Rows.Count; j++)
{
//取得当前IP
ip = table.Rows[j]["ip"].ToString();
//做一下基本判断
if (ip == null || ip.Length < 7)
{
continue;
}
//判断是否多IP
if (ip.Contains(",")) //说明一个SID设备对应多个IP
{
string[] curIPList = ip.Split(',');
bool ok = true;
剩余9页未读,继续阅读
资源评论
- VivyG2012-11-28C#调用ping,可以使用,主要使用返回值
zhaoweisheng2012
- 粉丝: 0
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功