Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9078649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:40:39+00:00 2026-06-16T19:40:39+00:00

I have an application that must read it’s own output that is written via

  • 0

I have an application that must read it’s own output that is written via

Console.WriteLine("blah blah");

I’m trying

Process p = Process.GetCurrentProcess();
StreamReader input = p.StandardOutput;
input.ReadLine();

But it doesn’t work because of “InvalidOperationException” at the second line. It says something like “StandardOutput wasn’t redirected, or the process has not been started yet” (translated)

How can I read my own output ? Is there another way to do that ? And to be complete how to write my own input ?

The application with the output is running already.

I want to read it’s output live in the same application. There is no 2nd app. Only one.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T19:40:41+00:00Added an answer on June 16, 2026 at 7:40 pm

    I’m just guessing as to what your intention might be but if you want to read the output from a application you started you can redirect the output.

     // Start the child process.
     Process p = new Process();
     // Redirect the output stream of the child process.
     p.StartInfo.UseShellExecute = false;
     p.StartInfo.RedirectStandardOutput = true;
     p.StartInfo.FileName = "Write500Lines.exe";
     p.Start();
     // Do not wait for the child process to exit before
     // reading to the end of its redirected stream.
     // p.WaitForExit();
     // Read the output stream first and then wait.
     string output = p.StandardOutput.ReadToEnd();
     p.WaitForExit();
    

    example from http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardoutput.aspx

    Edit:

    If you want to redirect the output of your current console application as your edit specifies you can use.

    private static void Main(string[] args)
    {
        StringWriter writer = new StringWriter();
        Console.SetOut(writer);
        Console.WriteLine("hello world");
    
        StringReader reader = new StringReader(writer.ToString());
        string str = reader.ReadToEnd();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write application that must read, modify and save some settings in
I have C# application that must store some information into MS SQL that would
ISS and ASP.NET. In my setup I have a web application that must be
I have a 32-bit application that must run on a Windows x64 server using
I have an application that is successfully deploying on tomcat, which I must migrate
I have application that brings response via Ajax and creates 5-20 new jQuery click
I have an application written in Java that uses a jar file(it uses more
I'm writing a C# application that must read the video properties of video files.
I have Winforms application that must create write to certain configuration file during usage.
I have an application that receives data in binary form through Bluetooth. I read

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.