473,791 Members | 3,028 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7788
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**@teraXNOSP AMXquest.com> wrote in message
news:#B******** ******@TK2MSFTN GP09.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***@microsof t.nospam0000.co m> wrote in message
news:Jkldb.6001 84$Ho3.117213@s ccrnsc03...
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**@teraXNOSP AMXquest.com> wrote in message
news:#B******** ******@TK2MSFTN GP09.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**@teraXNOSP AMXquest.com>
References: <#B************ **@TK2MSFTNGP09 .phx.gbl> <Jkldb.600184$H o3.117213@sccrn sc03>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.publi c.dotnet.genera l,microsoft.pub lic.dotnet.lang uages.csharpNNTP-Posting-Host: cs24313-53.austin.rr.co m 24.243.13.53
Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP11.phx.g bl
Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1877 16 microsoft.publi c.dotnet.genera l:110126X-Tomcat-NG: microsoft.publi c.dotnet.genera l

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***@microsof t.nospam0000.co m> wrote in message
news:Jkldb.600 184$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**@teraXNOSP AMXquest.com> wrote in message
news:#B******** ******@TK2MSFTN GP09.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
2083
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, ability is missing in IE and the latest versions of Netscape. Maybe someone knows a better way and can improve on this code, the following JavaScript code demonstrates how to write debug statements in a JavaScript program. I sure lots of people...
7
1809
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() instead of WinMain()) I created a new profile for the project and replaced precompile define _WINDOWS by _CONSOLE, and changed linker option /subsystem:windows to /subsystem:console.
10
3984
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
5952
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 between having and not because I'm printing many of them on loops, etc. Now, in Release mode Console.Writeline has something like #if (!Release), send the string to something like "/dev/null" or it is executed internally
7
2970
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. To do this i have Console.WriteLine("Hi server"); while (true)
1
319
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
5346
by: Sagaert Johan | last post by:
Hi Can a lot of Console.Writeline commands cause a program to run slower ? johan
4
2247
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
2678
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 before the console window closes, but "Start with debug" closes the window right away.
3
33382
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 the last period, and everything after it, should be discarded.
0
9669
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10427
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10207
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10155
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9995
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5431
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5559
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.