xcopy是否暂停,直到复制完成?

时间:2010-03-03 02:13:20

标签: c#-3.0 xcopy robocopy

对于像这样的C#控制台应用程序,使用xcopy或robocopy会更好吗? 此外,xcopy是否暂停,直到复制完成?

// copy web project to temp
            Process proc = new Process();
            proc.StartInfo.UseShellExecute = true;
            proc.StartInfo.FileName = @"C:\WINDOWS\system32\xcopy.exe";
            //proc.StartInfo.Arguments = @"C:\Users\Aron\Pictures\sql-help C:\temp\633965882226105579 /E /I";
            proc.StartInfo.Arguments = string.Format("{0} {1}  /E /I", TemplateDemoSiteFolder, SitePath);
            proc.Start();

            Thread.Sleep(9000); // pause for 9 seconds -not very safe though

1 个答案:

答案 0 :(得分:6)

而不是Thread.Sleep();你可能想用proc.WaitForExit();