Saturday, July 02, 2005

c# dir

using System;

using System.Diagnostics;

namespace ConsoleApplication8

{

class Class1

{

private static string ReverseUsingCharArrayCopyAndReverse(string input)
{
char[] reversed = input.ToCharArray();
Array.Reverse(reversed);
return new String(reversed);
}



static void Main(string[] args)

{

ProcessStartInfo proc = new ProcessStartInfo(); /* a process holder */

proc.FileName = "cmd.exe";

proc.RedirectStandardInput = false;

proc.RedirectStandardOutput = true;

proc.Arguments = "/c dir c:\\windows";

proc.UseShellExecute = false; /*do not show console for the process - a must*/

Process p = Process.Start(proc);

string res;

res = ReverseUsingCharArrayCopyAndReverse(p.StandardOutput.ReadToEnd());



System.Console.WriteLine(res);

p.WaitForExit(); /*wait indefinitely for the associated process to exit*/

}

}

}

0 Comments:

Post a Comment

<< Home