Beispiel #1
0
		public void Download(OnDownloadProgressHandler ProgressEvent, OnDownloadFinishHandler FinishEvent) {
			OnDownloadProgress = ProgressEvent;
			OnDownloadFinish = FinishEvent;

			// Just delete a file
			if (this.Action == EPatchAction.DataDelete || this.Action == 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);
		}