解决方案 »
- 关于ERP用户在线空闲状态问题
- 如何自动填写查询机票文本框
- c#写程序确实快啊,但是怎么把.net3.5和安装程序打成一个包。
- C# 调用DLL的问题 急!!!
- 求救VB和C#都通的高手!!!(FOR循环转不过来,则样在C#中实现object型变量进行for循环)
- winform中关于登陆窗口的验证问题!!
- 求助求助
- 我自己写了个COM+组件的项目,在另一个程序中想调用,却出现问题,望高手指点
- System.Random为什么不是System.Math.Random?
- 问一个弱弱的问题,在C#中,关闭程序后,如何让它自动重启!
- 有没有关于条形码的例子?
- 怎么给第三方控件(ActiveX)添加事件(急!!在线等)
Received Sent
Bytes 58537277 22523880
Unicast packets 129819 130761
Non-unicast packets 1670 1415
Discards 0 0
Errors 0 720
Unknown protocols 176800
IPv4 Statistics
Packets Received = 302013
Received Header Errors = 0
Received Address Errors = 289
";
Match m = Regex.Match(test, @"(?i)Bytes\s*(?<rev>\d+)\s*(?<send>\d+)");
if (m.Success)
{
richTextBox2.Text += m.Groups["rev"].Value + "\n";
richTextBox2.Text += m.Groups["send"].Value + "\n";
}
{
System.Diagnostics.Process _Process = new System.Diagnostics.Process();
_Process.StartInfo.FileName="CMD.EXE";
_Process.StartInfo.Arguments = "/C NETSTAT -SE";
_Process.StartInfo.CreateNoWindow = true;
_Process.StartInfo.UseShellExecute = false;
_Process.StartInfo.RedirectStandardOutput = true;
_Process.Start();
string _TempText = _Process.StandardOutput.ReadToEnd(); List<Bytes> _Value = new List<Bytes>(); int _StarIndex = _TempText.IndexOf("Bytes");
int _EndIndex = _TempText.IndexOf("Unicast packets"); string[] _Data = _TempText.Substring(_StarIndex, _EndIndex - _StarIndex).Split(new char[] { ' ', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); _Value.Add(new Bytes(_Data));
} public class Bytes
{
public long Recived = 0;
public long Sent = 0; public Bytes(string[] p_Data)
{
if (p_Data.Length != 3) return;
long.TryParse(p_Data[1],out Recived);
long.TryParse(p_Data[2], out Sent);
}
}这样字符串截取就可以了.