웹 서버에서 현재 버전의 .exe를 기반으로 파일을 다운로드하는 응용 프로그램을 만들었습니다. 모든 검사가 완료되었지만 모든 기능이 제대로 작동하지만 멈출 수있는 방법이 필요합니다. 파일 추출이 완료 될 때까지 기다리십시오. 느린 PC 및/또는 큰 파일의 경우에 대해 어떻게 가능합니까? 또한 추출이 완료된 후 파일을 삭제하려고합니다.C# 파일 압축 대기
추출은 winrar sfx 압축을 사용하여 수행 된 다음 응용 프로그램에서 파일을 다운로드하고 나중에 시작합니다.
미리 감사드립니다. 코드는 다음과 같습니다. 처음으로 네트워킹으로 작업하는 것은 처음이며, 여전히 자기 가르침을 가지고 있습니다. 그렇다면 의미있는 코멘트를 남겨 주시기 바랍니다.
private void Completed(object sender, AsyncCompletedEventArgs e)
{
Process.Start("update.exe");
}
private void downloadfile(string filenumber)
{
MessageBox.Show("Download working");
WebClient webClient = new WebClient();
webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);
webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);
webClient.DownloadFileAsync(new Uri("http://127.0.0.1/Update/update"+filenumber+".exe"), @"update.exe");
label1.Text = "Downloading Update" + filenumber + "...";
string filepath = "http://127.0.0.1/Update/update"+filenumber+".exe";
webClient.OpenRead(filepath);
Int64 bytes_total = Convert.ToInt64(webClient.ResponseHeaders["Content-Length"]);
string updatelength = Convert.ToString((bytes_total/1024).ToString());
label2.Text = updatelength + "KB";
}
당신은 어떻게 추출을 수행합니까? – CodeCaster
병렬 작업 라이브러리 http://msdn.microsoft.com/en-us/library/dd537609(v=vs.110).aspx를 확인하십시오. 어쩌면 Task.WaitAll – reggaeguitar
을 사용합니다. 나는 winrar를 사용하여 파일을 압축하고 백그라운드에서 자동 실행되도록 만들고 C#을 통해 파일을 자동으로 시작합니다. –