473,396 Members | 1,936 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.

Where does console output go?

I can see console output in the output window on VS, but how can you
see this text when running the app on a different machine or outside of
VS?

Thanks!

--- Andrew

Nov 17 '05 #1
8 2315
Hi,

Can you provide more info:

1) is a console application
2) are you using the Debug object?
3) are you using the trace object?
4) are you using the Console.WriteLine function?

Cheers
Salva

"AMeador" wrote:
I can see console output in the output window on VS, but how can you
see this text when running the app on a different machine or outside of
VS?

Thanks!

--- Andrew

Nov 17 '05 #2
You could use a streamwriter to redirect the output to the filesystem as
example:

using System;
using System.IO;
namespace ConsoleApplication4
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
FileStream fileStream = new FileStream(@"c:\Test.txt",
FileMode.Create);
StreamWriter streamWriter = new StreamWriter(fileStream);
Console.SetOut(streamWriter);
Console.WriteLine("Hello file");
streamWriter.Close();
}
}
}

Gabriel Lozano-Morán
Software Engineer
Sogeti
"AMeador" <am******@tampabay.rr.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
I can see console output in the output window on VS, but how can you
see this text when running the app on a different machine or outside of
VS?

Thanks!

--- Andrew

Nov 17 '05 #3
I am doing this form a Windows Form app and using the Console.Writeline
function. Sorry, about the confusion, I didn't think about console
output from these other sources.

Nov 17 '05 #4
Thanks - this will be useful to me. Does this mean that using
Console.Writeline function calls produce output that is only direclty
visable from within VS?

Nov 17 '05 #5
Behind the scenes a handle is retrieved to the active console screen buffer.
The Console uses a TextWriter to write output to the console. You can
retrieve a handle to input device to capture all the output but better is to
use a TextWriter to redirect the output.

Gabriel Lozano-Morán
Software Engineer
Sogeti

"AMeador" <am******@tampabay.rr.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Thanks - this will be useful to me. Does this mean that using
Console.Writeline function calls produce output that is only direclty
visable from within VS?

Nov 17 '05 #6
Thanks a lot - I appreciate the explanation!

--- Andrew

Nov 17 '05 #7
Ash
I think if you use a command line to load your GUI application and within
that application you use Console.Write(), you will see the output in the
command line window.
But if you load your application by double clicking your GUI exe, then you
won't see anything, simply because you don't have a Console open.
So its NOT ONLY within VS that you see the output.
(In java its clearer since usually you load the application from a command
line using C:\java <appName>)
-Ash
"AMeador" wrote:
Thanks a lot - I appreciate the explanation!

--- Andrew

Nov 17 '05 #8
If you don't want to change the source code of the console application you
can start the process from within your application with the output
redirected to a stream. In this example type exit in the console when you
run it to end the process:

using System;
using System.Diagnostics;
using System.IO;

namespace ConsoleApplication7
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
StreamWriter streamWriter = new StreamWriter(@"c:\output.txt");
Process process = new Process();
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.FileName = @"c:\windows\system32\cmd.exe";
process.StartInfo.UseShellExecute = false;
process.Start();
streamWriter.Write(process.StandardOutput.ReadToEn d());
streamWriter.Close();
}
}
}

Gabriel Lozano-Morán
Software Engineer
Sogeti

Nov 17 '05 #9

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

Similar topics

0
by: Keith Dick | last post by:
I'm trying to use the free command line C/C++ compiler for .NET and when I try to debug a simple C program that uses printf(), I don't see the output it produces. A console window does open when...
2
by: Boba | last post by:
Hi, I'm programming a WinForm application. I would like to enter commands that will send output that will help me to locate bugs in the future. I know that there is a way to send output by...
1
by: noleander | last post by:
Hi. I've got a C++ program written in Visual C++ 2003. The program is trivial, created with the Program-creation wizard: used the .NET "Form" template. The program has a trivial...
2
by: noleander | last post by:
Sorry if this is a trivial question :-) I've got several print statements in my code: fprintf ( stderr, ....); but when I run my program, I cannot find the output text in any window. My...
4
by: =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?= | last post by:
Hi; When my ASP.NET app is running on IIS, where does the Console.Out.WriteLine("hi there"); output go? -- thanks - dave david_at_windward_dot_net http://www.windwardreports.com
3
by: TC | last post by:
I'm trying to debug a console application, but I can't see the console output. I've seen many references which say that console output is supposed to appear on the Output window when the...
3
by: Curious | last post by:
I''ve created a simple Console Application in C#.NET (.NET 2.0), and I have the following code: Console.WriteLine("Now let us begin!"); However, the string, "Now let us begin!", never shows up...
27
by: CarlosMB | last post by:
Hello, I am writing code that uses a DLL which is supposed to print to console some useful information but for some reason it is not doing so. The environment is a bit complex to explain but...
5
by: jacob navia | last post by:
One of the many questions asked by people is that even if they write into standard output, the output doesn't show in the screen. This happens in windows systems since quite a long time. To...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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
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...
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.