473,396 Members | 1,772 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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

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
Jul 21 '05 #1
3 7736
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

Jul 21 '05 #2
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


Jul 21 '05 #3
Hi Bill,

Can you check my replied to your another post in this queue?
Subject: Write error on Read() ??

Regards,
Peter Huang
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.csharpNNTP-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:110126X-Tomcat-NG: microsoft.public.dotnet.general

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 dothis
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 "commandline" > 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
>
>




Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Robert | last post by:
Simple way of writing debug print statements in your JavaScript code. You need to have enabled popups in your browser. I liked the ability to write to the java console in Netscape 4.x. This,...
7
by: MuZZy | last post by:
HI I just wonder if someone can help me with this: I have a windows app project developed on VC++ 6.0. I need to adapt it to be able to compile as a console app as well (So it would call main()...
10
by: ion | last post by:
Hi! Is there a way to write messages to the javascript console? Like a debug.write() method? Thanks! Ion
2
by: Franco, Gustavo | last post by:
Hi, Console.WriteLine does something on Release mode? I have many of them in my application and I want to know if the performace could be affected, on debug mode I can see a big difference...
7
by: ~toki | last post by:
I have a full work app (server and client) that talk between two executables trought Console.WriteLine(); & Console.ReadLine(); I have the source code of the server. I need to make the client....
1
by: Grey | last post by:
Can I use System.Console.WriteLine('fasfasdf') in ASP.NET development as I need to print out some message in the console during the debug stage..
5
by: Sagaert Johan | last post by:
Hi Can a lot of Console.Writeline commands cause a program to run slower ? johan
4
by: Michael D. Ober | last post by:
Is there anyway the VB Compiler can detect if a program is a console application? I have some libraries that need to write to the console if the program is a console app. Thanks, Mike Ober.
5
by: Marin | last post by:
Right now my solution to this is adding Console.ReadLine at the end but I'm wondering if it's possible to do it automatically? If I chose "Start without debug" it does just that, it pauses right...
3
by: kj | last post by:
How can a script send (non-fatal) warnings and other such messages to Firefox's JavaScript console? Thanks! kj -- NOTE: In my address everything before the first period is backwards; and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.