c#怎么调用像dir一样的内部命令呢?用process的话只能打cmd /c dir 不过重定向输出的话不能得到想要的结果

解决方案 »

  1.   

    这是我的文章,正好回答了你的问题。在C#窗口中运行系统命令
    http://blog.csdn.net/gomoku/archive/2008/05/10/2428018.aspx
      

  2.   

                ProcessStartInfo start = new ProcessStartInfo("cmd.exe");
                start.RedirectStandardInput = true;
                start.RedirectStandardOutput = true;
                start.UseShellExecute = false;
                Process pro = Process.Start(start);
                pro.StandardInput.WriteLine("dir");
                pro.StandardInput.WriteLine("exit");
                MessageBox.Show(pro.StandardOutput.ReadToEnd());
                pro.Close();