System.Diagnostics.Process - Del Command

Posted by wonea on Stack Overflow See other posts from Stack Overflow or by wonea
Published on 2010-03-29T14:56:12Z Indexed on 2010/03/29 15:03 UTC
Read the original article Hit count: 526

Filed under:
|
|

I'm trying to start the del command using System.Diagnostic.Process. Basically I want to delete everything from the C:\ drive that has the filename of *.bat

System.Diagnostics.Process proc = new System.Diagnostics.Process(); string args = string.Empty; args += "*.bat";

proc.StartInfo.FileName = "del"; proc.StartInfo.WorkingDirectory = "C:\"; proc.StartInfo.Arguments = args.TrimEnd(); proc.Start();

However when code is ran an exception is thrown, "the system cannot find specified file." I know there definitely is files in that root folder containing that file extension.

© Stack Overflow or respective owner

Related posts about cmd

Related posts about c#