You must use the pipe ( | ) to output the dir output to the application. The redirect ( > ) that you used in your example will connect the Application.exe file and write the output of the dir command there, thus damaging your application.
To read data from the console, you must use the Console.ReadLine method, for example:
using System; public class Example { public static void Main() { string line; do { line = Console.ReadLine(); if (line != null) Console.WriteLine("Something.... " + line); } while (line != null); } }
user405725
source share