By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,485 Members | 1,031 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,485 IT Pros & Developers. It's quick & easy.

Console app (Debug)- how to redirect standard input/output?

P: n/a
I'm writing a console app (in C#) and I want to be able to redirect the
standard input/output streams when it's run at a command prompt. IOW I want
to support the "<" and ">" redirection syntax. The obvious way to do this is
by using the static Console type properties, In and Out. When trying to
debug the app in the IDE however, this doesn't appear to work. I've edited
the project properties and added the necessary text to the "command line"
argument property, but no joy.

So, have I missed something? Is there a way to simulate redirection from
within the IDE for a Console app?

Thanks in advance,
Bill
Nov 15 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Have you tried Console.SetIn() and Console.SetOut()? The ">" redirection
syntax is handled by the command-line interpreter and the IDE doesn't
simulate that. It just treats it as a regular string and the redirection
command gets passed as a string argument, which it looks like you've
discovered.
"Bill Cohagan" <bi**@teraXNOSPAMXquest.com> wrote in message
news:#B**************@TK2MSFTNGP09.phx.gbl...
I'm writing a console app (in C#) and I want to be able to redirect the
standard input/output streams when it's run at a command prompt. IOW I want to support the "<" and ">" redirection syntax. The obvious way to do this is by using the static Console type properties, In and Out. When trying to
debug the app in the IDE however, this doesn't appear to work. I've edited
the project properties and added the necessary text to the "command line"
argument property, but no joy.

So, have I missed something? Is there a way to simulate redirection from
within the IDE for a Console app?

Thanks in advance,
Bill

Nov 15 '05 #2

P: n/a
Bret-
Yes, I've tried SetIn and SetOut, but that means I have to execute
different code in the IDE than I do "in real life", not a very robust
situation. As it turns out I'm having major problems with just using
Console.In in the EXE; i.e., not in the IDE. I'm building a validating XML
reader around that input stream and I'm getting an error complaining that
the object doesn't support a write (?).

Thanks for the response,
Bill

"Bret Mulvey" <br***@microsoft.nospam0000.com> wrote in message
news:Jkldb.600184$Ho3.117213@sccrnsc03...
Have you tried Console.SetIn() and Console.SetOut()? The ">" redirection
syntax is handled by the command-line interpreter and the IDE doesn't
simulate that. It just treats it as a regular string and the redirection
command gets passed as a string argument, which it looks like you've
discovered.
"Bill Cohagan" <bi**@teraXNOSPAMXquest.com> wrote in message
news:#B**************@TK2MSFTNGP09.phx.gbl...
I'm writing a console app (in C#) and I want to be able to redirect the
standard input/output streams when it's run at a command prompt. IOW I want
to support the "<" and ">" redirection syntax. The obvious way to do this is
by using the static Console type properties, In and Out. When trying to
debug the app in the IDE however, this doesn't appear to work. I've

edited the project properties and added the necessary text to the "command line" argument property, but no joy.

So, have I missed something? Is there a way to simulate redirection from
within the IDE for a Console app?

Thanks in advance,
Bill


Nov 15 '05 #3

P: n/a

Hi Bill,

I think you can compile your program, then open the console window.
Drag the exe file that your program generated into the console window, then
you can add
paramters after this exe file name.

In you error problem, I think you did not express clear, what exception did
you get?

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| From: "Bill Cohagan" <bi**@teraXNOSPAMXquest.com>
| References: <#B**************@TK2MSFTNGP09.phx.gbl>
<Jkldb.600184$Ho3.117213@sccrnsc03>
| Subject: Re: Console app (Debug)- how to redirect standard input/output?
| Date: Sat, 27 Sep 2003 15:19:22 -0500
| Lines: 46
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <ug**************@TK2MSFTNGP11.phx.gbl>
| Newsgroups:
microsoft.public.dotnet.general,microsoft.public.d otnet.languages.csharp
| NNTP-Posting-Host: cs24313-53.austin.rr.com 24.243.13.53
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP11.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.languages.csharp:187716
microsoft.public.dotnet.general:110126
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Bret-
| Yes, I've tried SetIn and SetOut, but that means I have to execute
| different code in the IDE than I do "in real life", not a very robust
| situation. As it turns out I'm having major problems with just using
| Console.In in the EXE; i.e., not in the IDE. I'm building a validating XML
| reader around that input stream and I'm getting an error complaining that
| the object doesn't support a write (?).
|
| Thanks for the response,
| Bill
|
| "Bret Mulvey" <br***@microsoft.nospam0000.com> wrote in message
| news:Jkldb.600184$Ho3.117213@sccrnsc03...
| > Have you tried Console.SetIn() and Console.SetOut()? The ">"
redirection
| > syntax is handled by the command-line interpreter and the IDE doesn't
| > simulate that. It just treats it as a regular string and the redirection
| > command gets passed as a string argument, which it looks like you've
| > discovered.
| >
| >
| > "Bill Cohagan" <bi**@teraXNOSPAMXquest.com> wrote in message
| > news:#B**************@TK2MSFTNGP09.phx.gbl...
| > > I'm writing a console app (in C#) and I want to be able to redirect
the
| > > standard input/output streams when it's run at a command prompt. IOW I
| > want
| > > to support the "<" and ">" redirection syntax. The obvious way to do
| this
| > is
| > > by using the static Console type properties, In and Out. When trying
to
| > > debug the app in the IDE however, this doesn't appear to work. I've
| edited
| > > the project properties and added the necessary text to the "command
| line"
| > > argument property, but no joy.
| > >
| > > So, have I missed something? Is there a way to simulate redirection
from
| > > within the IDE for a Console app?
| > >
| > > Thanks in advance,
| > > Bill
| > >
| > >
| >
| >
|
|
|

Nov 15 '05 #4

P: n/a
Jeffrey-
The error I got is described more precisely in my other posting (Write
error on Read()??) to which you've already responded, although I've
responded to that requesting that you consider this further.

Thanks for responding,
Bill

"Jeffrey Tan[MSFT]" <v-*****@online.microsoft.com> wrote in message
news:1V**************@cpmsftngxa06.phx.gbl...

Hi Bill,

I think you can compile your program, then open the console window.
Drag the exe file that your program generated into the console window, then you can add
paramters after this exe file name.

In you error problem, I think you did not express clear, what exception did you get?

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| From: "Bill Cohagan" <bi**@teraXNOSPAMXquest.com>
| References: <#B**************@TK2MSFTNGP09.phx.gbl>
<Jkldb.600184$Ho3.117213@sccrnsc03>
| Subject: Re: Console app (Debug)- how to redirect standard input/output?
| Date: Sat, 27 Sep 2003 15:19:22 -0500
| Lines: 46
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <ug**************@TK2MSFTNGP11.phx.gbl>
| Newsgroups:
microsoft.public.dotnet.general,microsoft.public.d otnet.languages.csharp
| NNTP-Posting-Host: cs24313-53.austin.rr.com 24.243.13.53
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP11.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.languages.csharp:187716
microsoft.public.dotnet.general:110126
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Bret-
| Yes, I've tried SetIn and SetOut, but that means I have to execute
| different code in the IDE than I do "in real life", not a very robust
| situation. As it turns out I'm having major problems with just using
| Console.In in the EXE; i.e., not in the IDE. I'm building a validating XML | reader around that input stream and I'm getting an error complaining that | the object doesn't support a write (?).
|
| Thanks for the response,
| Bill
|
| "Bret Mulvey" <br***@microsoft.nospam0000.com> wrote in message
| news:Jkldb.600184$Ho3.117213@sccrnsc03...
| > Have you tried Console.SetIn() and Console.SetOut()? The ">"
redirection
| > syntax is handled by the command-line interpreter and the IDE doesn't
| > simulate that. It just treats it as a regular string and the redirection | > command gets passed as a string argument, which it looks like you've
| > discovered.
| >
| >
| > "Bill Cohagan" <bi**@teraXNOSPAMXquest.com> wrote in message
| > news:#B**************@TK2MSFTNGP09.phx.gbl...
| > > I'm writing a console app (in C#) and I want to be able to redirect
the
| > > standard input/output streams when it's run at a command prompt. IOW I | > want
| > > to support the "<" and ">" redirection syntax. The obvious way to do
| this
| > is
| > > by using the static Console type properties, In and Out. When trying
to
| > > debug the app in the IDE however, this doesn't appear to work. I've
| edited
| > > the project properties and added the necessary text to the "command
| line"
| > > argument property, but no joy.
| > >
| > > So, have I missed something? Is there a way to simulate redirection
from
| > > within the IDE for a Console app?
| > >
| > > Thanks in advance,
| > > Bill
| > >
| > >
| >
| >
|
|
|

Nov 15 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.