c# console app

G

Guest

How do i trap the incomming data to the console?
lets say I wrote a console app that pings another computer in the network.
I see the following in the console:

Reply from 180.100.24.5: bytes=32 time<10ms TTL=127
Reply from 180.100.24.5: bytes=32 time<10ms TTL=127
Reply from 180.100.24.5: bytes=32 time<10ms TTL=127

I want to trap all this into a string. How can I do this?

Thanks in advance
 
G

Guest

I already use processInfo but how do i trap the text that is written on the
console?

Thanks
 
S

Someone

using System;
using System.Diagnostics;

class Class1
{
static void Main(string[] args)
{
ProcessStartInfo procInfo = new ProcessStartInfo("ping", "127.0.0.1");
procInfo.CreateNoWindow= false;
procInfo.UseShellExecute = false;
procInfo.WindowStyle = ProcessWindowStyle.Hidden;
procInfo.RedirectStandardOutput = true;
Process pro = new Process();
pro.StartInfo = procInfo;
pro.Start();
Console.WriteLine(pro.StandardOutput.ReadToEnd());
Console.ReadLine(); // just to wait...
}
}
 
G

Guest

Thanks Someone,
But how can I trap pro.StandardOutput.ReadToEnd() into a string so that i
can find a text in it?

Thanks

Someone said:
using System;
using System.Diagnostics;

class Class1
{
static void Main(string[] args)
{
ProcessStartInfo procInfo = new ProcessStartInfo("ping", "127.0.0.1");
procInfo.CreateNoWindow= false;
procInfo.UseShellExecute = false;
procInfo.WindowStyle = ProcessWindowStyle.Hidden;
procInfo.RedirectStandardOutput = true;
Process pro = new Process();
pro.StartInfo = procInfo;
pro.Start();
Console.WriteLine(pro.StandardOutput.ReadToEnd());
Console.ReadLine(); // just to wait...
}
}


me said:
I already use processInfo but how do i trap the text that is written on the
console?

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top