471,348 Members | 1,601 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,348 software developers and data experts.

c# console app

me
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
Jul 21 '05 #1
5 2848

You can use the ProcessInfo class and trap standard output from any DOS
command.

me wrote:
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

Jul 21 '05 #2
me
I already use processInfo but how do i trap the text that is written on the
console?

Thanks

"ja*****@texeme.com" wrote:

You can use the ProcessInfo class and trap standard output from any DOS
command.

me wrote:
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

Jul 21 '05 #3
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" <me@discussions.microsoft.com> wrote in message
news:8A**********************************@microsof t.com...
I already use processInfo but how do i trap the text that is written on the
console?

Thanks

"ja*****@texeme.com" wrote:

You can use the ProcessInfo class and trap standard output from any DOS
command.

me wrote:
> 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


Jul 21 '05 #4
me
Thanks Someone,
But how can I trap pro.StandardOutput.ReadToEnd() into a string so that i
can find a text in it?

Thanks

"Someone" wrote:
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" <me@discussions.microsoft.com> wrote in message
news:8A**********************************@microsof t.com...
I already use processInfo but how do i trap the text that is written on the
console?

Thanks

"ja*****@texeme.com" wrote:

You can use the ProcessInfo class and trap standard output from any DOS
command.

me wrote:
> 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


Jul 21 '05 #5
me
I see how you did it Thanks alottttttttttt

"me" wrote:
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

Jul 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

19 posts views Thread by Dave | last post: by
5 posts views Thread by Publicjoe | last post: by
17 posts views Thread by MumboJumbo | last post: by
5 posts views Thread by portroe | last post: by
3 posts views Thread by julianmoors | last post: by
1 post views Thread by John Wright | last post: by
reply views Thread by Ronak mishra | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.