how to write a dos command in c# i do it in c like
system("dir");how in c# pls fast
how to write a dos command in c# i do it in c like
system("dir");how in c# pls fast
لا اله الا الله .......................................... محمد رسول الله
System.Process.Start("cmd.exe","/c --commandName--");
example
System.Diagnostics.Process.Start("cmd","/c netstat -ano");
System.Diagnostics.Process.Start("cmd","/c dir/p");
but
for commands that run in the MS-Dos ,they are executed so fast then the command window disappears,and i can't watch the result
do u have a soultion
here is the solution:
Process p = new Process();
p.StartInfo.FileName = "cmd";
p.StartInfo.Arguments = "/c netstat -ano";
p.StartInfo.CreateNoWindow = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardInput = true;
p.Start();
//get the output from cmd
string output = p.StandardOutput.ReadToEnd();
//save the output to a file
StreamWriter sw = new StreamWriter(@"C:\fff.txt");
sw.Write(output);
sw.Close();
fs.Close();
هذا الموضوع مغلق.