System.Diagnostics.Process - Del Command
- by wonea
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.