Esempio n. 1
0
        /// <remarks>
        /// Please exuse the signature and exception handling of this
        /// method. This is not my normal style.
        /// </remarks>
        private async Task <string> DownloadFile(string address)
        {
            string html;

            logger.WriteLine("Downloading address: " + address);
            try
            {
                using (IDownloaderClient downloaderClient = createClient())
                {
                    html = await downloaderClient.DownloadStringAsync(address);
                }
                logger.WriteLine("Chars read: " + html.Length);
                logger.WriteLine("Beginning: " + html.Substring(0, 200));
                return(html);
            }
            catch (System.Net.WebException webException)
            {
                logger.WriteLine("Something went wrong with the download: " + webException.Message);
                throw;
            }
        }