stevenk140
Programmer
I want to run a command like "dir" or "del <filename". How do you do this in C#? In C\C++ you can do a System(cmd); What is the C# equivalent?
Steven
Steven
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
System.Diagnostics.Process P = null;
try {
P = new System.Diagnostics.Process();
string WorkingDirectory = "C:\\docs";
//P.StartInfo.RedirectStandardOutput = true;
P.StartInfo.CreateNoWindow = true;
P.StartInfo.WorkingDirectory = WorkingDirectory;
P.StartInfo.FileName = "C:\\tmp.bat";
//P.StartInfo.Arguments = ""; //P.EnableRaisingEvents = true;
P.StartInfo.UseShellExecute = false;
P.Start();
}
catch(Exception er)
{
string sMsg = "Error in starting process " + er.GetType() + er.Message;
}