private async Task <string> DownloadResultFileAsyncImpl(string localResultDirectoryName, string localResultFileName, bool decompress, bool overwrite) { if (FinalStatus == null) { await GetStatusAsync().ConfigureAwait(false); if (FinalStatus == null) { throw new ReportingOperationInProgressException(); } } if (!_statusProvider.IsSuccessStatus(FinalStatus)) { throw new ReportingOperationCouldNotBeCompletedException(); } // If the status is Success and the ResultFileUrl is null, then there is no data to download. if (_statusProvider.IsSuccessStatus(FinalStatus) && !_statusProvider.IsResultFileUrl(FinalStatus)) { return(null); } var effectiveFileName = localResultFileName ?? RequestId; var fullPath = Path.Combine(localResultDirectoryName, effectiveFileName); var zipResultFilePath = Path.ChangeExtension(fullPath, "zip"); await DownloadResultFileZipAsync(FinalStatus.ResultFileUrl, zipResultFilePath, overwrite).ConfigureAwait(false); if (!decompress) { return(zipResultFilePath); } var extractedFile = ZipExtractor.ExtractFirstEntryToFile(zipResultFilePath, fullPath, localResultFileName == null, overwrite); FileSystem.DeleteFile(zipResultFilePath); return(extractedFile); }