public void MergeParallelDownloadedChunk(string destinationPath) { using (FileStream destinationFs = new FileStream(destinationPath, FileMode.Append)) { foreach (var tempFile in tempFilesDictionary.OrderBy(x => x.Key)) { long chunkDownloaded = getReadRanges.Where(x => x.Start == tempFile.Key).Select(y => y.End).FirstOrDefault(); double percentdownloaded = (chunkDownloaded / Convert.ToDouble(downloadResult.Size)) * 100; DownloadStatusEventArgs args = new DownloadStatusEventArgs(); args.percentDownloaded = (long)percentdownloaded; OnDownloadStarted(args); byte[] tempFileBytes = File.ReadAllBytes(tempFile.Value); destinationFs.Write(tempFileBytes, 0, tempFileBytes.Length); File.Delete(tempFile.Value); } } }
protected virtual void OnDownloadStarted(DownloadStatusEventArgs e) { DownloadingStatus?.Invoke(this, e); }