Ejemplo n.º 1
0
        protected virtual string GetResponseString(string url)
        {
            WebClient webClient = new CompressionWebClient();

            webClient.Encoding = _encoding;
            return(webClient.DownloadString(url));
        }
Ejemplo n.º 2
0
 public virtual async Task <byte[]> DownloadDataAsync(string url)
 {
     try
     {
         WebClient webClient = new CompressionWebClient();
         webClient.Encoding = _encoding;
         return(await webClient.DownloadDataTaskAsync(url).ConfigureAwait(false));
     }
     catch (Exception ex)
     {
         ServiceRegistration.Get <ILogger>().Error("Exception opening stream from '{0}'", ex, url);
         return(null);
     }
 }
Ejemplo n.º 3
0
        public virtual async Task <bool> DownloadFileAsync(string url, string downloadFile, bool overwrite)
        {
            if (!overwrite && File.Exists(downloadFile))
            {
                return(true);
            }
            try
            {
                WebClient webClient = new CompressionWebClient();
                webClient.Encoding = _encoding;
                await webClient.DownloadFileTaskAsync(url, downloadFile).ConfigureAwait(false);

                return(true);
            }
            catch (Exception ex)
            {
                ServiceRegistration.Get <ILogger>().Error("Exception downloading file from '{0}' to '{1}'", ex, url, downloadFile);
                return(false);
            }
        }