Beispiel #1
0
        private async Task DownloadWithProgress(FileStream fileStream, Action <double, string> reportProgress)
        {
            try
            {
                // get the file contents;
                var requestMessage = new HttpRequestMessage(HttpMethod.Get, Url);
                GitHubContainer.AddCromeHeaders(requestMessage);

                using (var client = new HttpClient())
                {
                    using (HttpResponseMessage response = await client.SendAsync(requestMessage))
                    {
                        using (var readData = await response.Content.ReadAsStreamAsync())
                        {
                            var totalBytes = response.Content.Headers.ContentLength;
                            await HttpProgress.ProcessContentStream(totalBytes, readData, fileStream, reportProgress);
                        }
                    }
                }
            }
            catch
            {
                // Previous code swallowed errors, doing the same for now
            }
        }
        private async Task DownloadWithProgress(FileStream fileStream, Action <double, string> reportProgress)
        {
            try
            {
                // get the file contents;
                var downLoadUrl = new HttpRequestMessage(HttpMethod.Get, Url);
                GitHubContainer.AddCromeHeaders(downLoadUrl);

                using (var client = new HttpClient())
                {
                    using (HttpResponseMessage contentResponse = await client.SendAsync(downLoadUrl))
                    {
                        using (var readData = await contentResponse.Content.ReadAsStreamAsync())
                        {
                            await readData.CopyToAsync(fileStream);
                        }
                    }
                }
            }
            catch
            {
                // Previous code swallowed errors, doing the same for now
            }
        }