using System;
using System.Diagnostics;
class MainClass
{
public static void Main()
{
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.Arguments = "/c dir *.cs";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.Start();
string output = p.StandardOutput.ReadToEnd();
Console.WriteLine("Output:");
Console.WriteLine(output); }
}
Output:
Volume in drive C has no label.
Volume Serial Number is 8424-900C
Directory of C:\Java_Dev\WEB\dev\CSharp
25/03/2007 12:31 PM 745 Abaseclassreferencecanrefertoaderivedclassobject.cs
25/03/2007 12:31 PM 3,435 AbetterwaytooverloadandforTwoDimension.cs
25/03/2007 12:34 PM 549 AbortaThread.cs
25/03/2007 12:37 PM 970 Aboutathread.cs