public void Download(OnDownloadProgressHandler ProgressEvent, OnDownloadFinishHandler FinishEvent) { OnDownloadProgress = ProgressEvent; OnDownloadFinish = FinishEvent; // just Delete a File if (this.PatchAction == EPatchAction.DataDelete || this.PatchAction == EPatchAction.GrfDelete) { if (OnDownloadFinish != null) { OnDownloadFinish(this, false); } return; } FilePath = Path.GetTempFileName(); if (File.Exists(FilePath)) { File.Delete(FilePath); } TimeoutWebClient client = new TimeoutWebClient(); client.BaseAddress = DownloadUrl; client.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(client_DownloadFileCompleted); client.DownloadProgressChanged += new System.Net.DownloadProgressChangedEventHandler(client_DownloadProgressChanged); client.DownloadFileAsync(new Uri(DownloadUrl), FilePath, client); }
public void Download(string Url) { mPatchListUrl = Url.Substring(0, Url.LastIndexOf('/') + 1); mPatchListPath = Path.GetTempFileName(); mClient.BaseAddress = Url; mClient.TimeOut = 2000; mClient.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(CLient_DownloadFileCompleted); mClient.DownloadFileAsync(new Uri(Url), mPatchListPath); }