我使用 Robocopy 将文件从一台计算机移动到另一台计算机。我正在使用下面的代码:
public void MoveRecords()
{
try
{
using (Process Robocopy = new Process())
{
Robocopy.StartInfo.FileName = this._commandPromptCommand;
Robocopy.StartInfo.Arguments = this._commandPromptString;
Robocopy.StartInfo.UseShellExecute = false;
Robocopy.StartInfo.CreateNoWindow = true;
Robocopy.Start();
DateTime StartTime = DateTime.Now;
if (Robocopy.WaitForExit(AppSettings.MaxMoveOperationWaitTime))
{
TimeSpan ElapsedTime = DateTime.Now - StartTime;
this._logRobocopyExitCode(Robocopy.ExitCode, ElapsedTime);
}
else
{
Logger.Write(string.Format("Timeout occured for the move operation of {0} from {1}. ", _getFilesInProgress(), this._ip), EventLogEntryType.Error);
Robocopy.Kill();
}
}
}
catch (Exception ex)
{
Logger.Write(ex, EventLogEntryType.Error);
}
}
当我查看任务管理器时,我看到了许多“控制台窗口主机”和“Microsoft Robocopy”进程。您可以从下面的屏幕截图中看到情况。
我怎么解决这个问题?