I and not sure if this is the correct forum to post this queston. Any ideas
will be appreciated.
Need to call a base windows console command function (like dir or chkdsk)
and capture the results for further processing.
Two questions:
(1) Is it possible to code a program in C# to do this? - I know everyone
says I should use Perl instead.
(2) Can I do it without reading or writing any files to disk?
> Need to call a base windows console command function (like dir or chkdsk)
> and capture the results for further processing.
>
> Two questions:
> (1) Is it possible to code a program in C# to do this? - I know everyone
> says I should use Perl instead.
Yes - you use the System.Diagnostics.Process class. (For a shell
command like dir, I think you'll have to run command.exe, and pass it
a "dir" argument - I haven't tried this.)
> (2) Can I do it without reading or writing any files to disk?
Yes.
Here's an example that I wrote (two days ago, fwiw) to capture PING
output:
private static string PingServer()
{
Process Ping = new Process();
Ping.StartInfo.UseShellExecute = false;
Ping.StartInfo.FileName = "ping.exe";
Ping.StartInfo.Arguments = @"-n 1 -r 9 www.midnightbeach.com";
Ping.StartInfo.CreateNoWindow = true;
Ping.StartInfo.RedirectStandardOutput = true;
Ping.Start();
return Ping.StandardOutput.ReadToEnd();
}

Signature
<http://www.midnightbeach.com> Contracting, consulting, training
.NET 2.0 for Delphi Programmers <http://www.midnightbeach.com/.net>
In production - in stores by June