C# 执行Cmd窗口中的命令 [复制文件实例]

   /// <summary>
/// 复制文件夹
/// </summary>
/// <param name="sCmd"></param>
private void ExcuteXCopyCmd(string sCmd)
{
System.Diagnostics.Process proIP = new System.Diagnostics.Process();
proIP.StartInfo.FileName = "cmd.exe";
proIP.StartInfo.UseShellExecute = false;
proIP.StartInfo.RedirectStandardInput = true;
proIP.StartInfo.RedirectStandardOutput = true;
proIP.StartInfo.RedirectStandardError = true;
proIP.StartInfo.CreateNoWindow = true;
proIP.Start();
proIP.StandardInput.WriteLine(sCmd);
proIP.StandardInput.WriteLine("exit");
string strResult = proIP.StandardOutput.ReadToEnd();
//lstLog.Items.Insert(0, string.Format("【{0}】子目录批量复制命令结果:", strResult));
Log(string.Format("【{0}】子目录批量复制命令结果", strResult));
proIP.Close(); }
上一篇:CWMP开源代码研究番外篇——博通方案


下一篇:安装程序无法复制文件 convlog.exe的解决方法