473,624 Members | 2,637 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
Nov 15 '05 #1
4 8734
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

Nov 15 '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


Nov 15 '05 #3

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**@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.csharp
| NNTP-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:110126
| X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.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***@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
| > >
| > >
| >
| >
|
|
|

Nov 15 '05 #4
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.mi crosoft.com> wrote in message
news:1V******** ******@cpmsftng xa06.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**@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.csharp
| NNTP-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:110126
| X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.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***@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
| > >
| > >
| >
| >
|
|
|

Nov 15 '05 #5

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

Similar topics

1
2077
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
1800
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
3971
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
5928
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
2961
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
5326
by: Sagaert Johan | last post by:
Hi Can a lot of Console.Writeline commands cause a program to run slower ? johan
4
2237
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
2670
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
33369
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
8251
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
8182
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8688
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
8635
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...
0
8494
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
7178
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
5570
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
4188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2614
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.