---
title: "RedirectStandardOutput properties in C#"  
description: "Suppose that we have a console application which is written in any language and we want to invoke it directly in our C# Programming, without having to"  
author: "Anonymous User"  
published: 2011-08-25  
updated: 2019-09-07  
canonical: https://www.mindstick.com/articles/617/redirectstandardoutput-properties-in-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# RedirectStandardOutput properties in C#

Suppose that we have a [console application](https://www.mindstick.com/forum/160510/how-to-fetch-data-from-the-database-in-the-dot-net-console-application-using-c-sharp) which is written in any language and we want to invoke it directly in our [C# Programming](https://www.mindstick.com/blog/482/main-and-command-line-arguments-in-c-sharp-programming), without having to rely on [output files](https://answers.mindstick.com/qa/34222/how-to-review-salesforce-data-loader-output-files) being written to the disk. The Process and ProcessStartInfo classes (available in System.Diagnostics [namespace](https://www.mindstick.com/articles/28/namespace-in-dot-net)) in the [C# language](https://www.mindstick.com/forum/157570/how-to-use-face-recognition-in-c-sharp-language-for-attendance-register-software) provide a way to redirect the standard output of a process executable to the [C# program](https://www.mindstick.com/forum/157401/c-sharp-program-to-find-all-the-divisible-numbers-by-7-which-are-less-than-100) into a [StreamReader](https://www.mindstick.com/forum/1934/check-if-a-streamreader-can-read-another-line) and get it into C# string variable.\

Example: RedirectStandardOutput of invoking console [application in C#](https://www.mindstick.com/forum/33721/how-to-create-columns-in-datagridview-windows-application-in-c-sharp) program

```
using System.Diagnostics;using System.Threading;using System.IO;namespace ConsoleProcessTest{     class Program    {         static voidMain(string[] args)         {               ProcessStartInfo myStart= new ProcessStartInfo();    //.exe path with exe file name            myStart.FileName= @"C:\Windows\Microsoft.NET\Framework\v3.5\csc.exe";           //indicating whether to use the operating system shell to start the process            myStart.UseShellExecute= false;             // Enable the RedirectStandardOutput             myStart.RedirectStandardOutput= true;             // start process of processstartinfo             Process myProcess= Process.Start(myStart);             // read all text from process stream reader                 string message= myProcess.StandardOutput.ReadToEnd();             // write the message on console                 Console.WriteLine(message);                 Console.ReadKey();         }           }     }
```

##### Output:

![RedirectStandardOutput properties in C#](https://www.mindstick.com/mindstickarticle/592efe65-08b4-4195-814a-1e8e637adbed/images/a8aa0652-385e-4558-9182-c31d27cede35.png)

Note: When you use RedirectStandarOutput then you must be specify the filename.

\

---

Original Source: https://www.mindstick.com/articles/617/redirectstandardoutput-properties-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
