主题:[求助]关于C#中调用DOS命令!
最近做一个程序需要用到DOS的命令行程序,按照网上搜到的和MSDN里面的提示,我写了程序。
这段程序在VISTA系统和VS.NET2005的时候,没有任何问题,但是换到XP系统的时候,一运行就死机,这是什么问题啊?
调试了一下,单独转向输入流或者单独转向输出流都没有问题,就是两个一起转就死机,是不是顺序不对??请高人指点!
Process process = new Process();
process.StartInfo.FileName = "cmd.exe"; // Run this program
process.StartInfo.UseShellExecute = false; // Must be false
process.StartInfo.RedirectStandardInput = true; // Redirect input stream
process.StartInfo.RedirectStandardOutput = true; // Redirect output stream
process.StartInfo.CreateNoWindow = true; // All commands run in one window
process.Start();
process.StandardInput.WriteLine("ver");
process.StandardInput.WriteLine("exit");
string output = process.StandardOutput.ReadToEnd();
process.WaitForExit();
process.Close();
MessageBox.Show(output);
这段程序在VISTA系统和VS.NET2005的时候,没有任何问题,但是换到XP系统的时候,一运行就死机,这是什么问题啊?
调试了一下,单独转向输入流或者单独转向输出流都没有问题,就是两个一起转就死机,是不是顺序不对??请高人指点!
Process process = new Process();
process.StartInfo.FileName = "cmd.exe"; // Run this program
process.StartInfo.UseShellExecute = false; // Must be false
process.StartInfo.RedirectStandardInput = true; // Redirect input stream
process.StartInfo.RedirectStandardOutput = true; // Redirect output stream
process.StartInfo.CreateNoWindow = true; // All commands run in one window
process.Start();
process.StandardInput.WriteLine("ver");
process.StandardInput.WriteLine("exit");
string output = process.StandardOutput.ReadToEnd();
process.WaitForExit();
process.Close();
MessageBox.Show(output);