private void StartDownload() { if (!string.IsNullOrEmpty(URL) && Status == DownloaderFormStatus.Waiting) { Status = DownloaderFormStatus.DownloadStarted; btnAction.Text = Resources.DownloaderForm_StartDownload_Cancel; SavePath = Path.Combine(Path.GetTempPath(), Filename); fileStream = new FileStream(SavePath, FileMode.Create, FileAccess.Write, FileShare.Read); fileDownloader = new FileDownloader(URL, fileStream, Proxy, AcceptHeader); fileDownloader.FileSizeReceived += (v1, v2) => ChangeProgress(); fileDownloader.DownloadStarted += (v1, v2) => ChangeStatus(Resources.DownloaderForm_StartDownload_Downloading_); fileDownloader.ProgressChanged += (v1, v2) => ChangeProgress(); fileDownloader.DownloadCompleted += fileDownloader_DownloadCompleted; fileDownloader.ExceptionThrowed += (v1, v2) => ChangeStatus(fileDownloader.LastException.Message); fileDownloader.StartDownload(); ChangeStatus(Resources.DownloaderForm_StartDownload_Getting_file_size_); } }
private void StartDownload() { if (!string.IsNullOrEmpty(URL) && Status == DownloaderFormStatus.Waiting) { Status = DownloaderFormStatus.DownloadStarted; btnAction.Text = Resources.DownloaderForm_StartDownload_Cancel; string folderPath = Path.Combine(Path.GetTempPath(), "ShareX"); Helpers.CreateDirectory(folderPath); DownloadLocation = Path.Combine(folderPath, Filename); fileDownloader = new FileDownloader(URL, DownloadLocation, Proxy, AcceptHeader); fileDownloader.FileSizeReceived += (v1, v2) => ChangeProgress(); fileDownloader.DownloadStarted += (v1, v2) => ChangeStatus(Resources.DownloaderForm_StartDownload_Downloading_); fileDownloader.ProgressChanged += (v1, v2) => ChangeProgress(); fileDownloader.DownloadCompleted += fileDownloader_DownloadCompleted; fileDownloader.ExceptionThrown += (v1, v2) => ChangeStatus(fileDownloader.LastException.Message); fileDownloader.StartDownload(); ChangeStatus(Resources.DownloaderForm_StartDownload_Getting_file_size_); } }