有一種方法可以防止用戶在他的過程中關閉7za.exe窗口?我需要顯示文件夾提取的進展,但如果用戶關閉窗口,這可能會導致我的C#程序中出現一些錯誤。避免用戶關閉7za.exe程序,直到進程完成
ExtractForm extractForm = new ExtractForm();
extractForm.Show();
Process zipProcess = new Process();
using (zipProcess)
{
zipProcess.StartInfo.UseShellExecute = false; //Show the cmd.
zipProcess.StartInfo.RedirectStandardOutput = true;
zipProcess.OutputDataReceived += (object sender, DataReceivedEventArgs outline) =>
{
LogFileExtract(outline.Data);
// Add args to a TextBox, ListBox, or other UI element
};
zipProcess.StartInfo.CreateNoWindow = true;
zipProcess.StartInfo.FileName = pathToZip;
zipProcess.StartInfo.Arguments = args;
zipProcess.Start();
zipProcess.BeginOutputReadLine();
zipProcess.WaitForExit(); //Wait the process to finish completely.
}
extractForm.Close();
}
http://stackoverflow.com/questions/5377423/hide-console-window-from-process-start-c-sharp這是否給你一個答案? – Will
不,我想要控制檯窗口,但我不希望用戶自己關閉控制檯窗口 –
然後,您可能是SOL。 – Will