System.Diagnostics.Process pro = new System.Diagnostics.Process();
pro.StartInfo.FileName = "cmd.exe";
pro.StartInfo.UseShellExecute = false;
pro.StartInfo.RedirectStandardInput = true;
pro.StartInfo.RedirectStandardOutput = true;
pro.StartInfo.CreateNoWindow = true;
pro.Start();
//pro.StandardInput.WriteLine("net use \\\\202.149.225.121\\ipc$ \"AISchina_Admin\" /user:\"administrator\"");
pro.StandardInput.WriteLine("cd D:\\程序\\5千png");
pro.StandardInput.WriteLine("dir *.*");
StreamReader reader = pro.StandardOutput;
// 截取输出流 pro.StandardInput.WriteLine("exit");
string line = reader.ReadLine();
// 每次读一行 while (!reader.EndOfStream) // 不为空则读取 { textBox2.AppendText(line + Environment.NewLine);
// Environment .NewLine 换行 line = reader.ReadLine();
}pro.WaitForExit();
pro.Close();