Exemple #1
0
        public static async Task HttpDownloadFileAsync(
            string uri,
            string path,
            Configure <WebClient> clientConfigurator        = null,
            Action <WebHeaderCollection> headerConfigurator = null,
            Action <WebRequest> requestConfigurator         = null)
        {
            WebClient webClient = new CustomWebClient(requestConfigurator);

            webClient = clientConfigurator.InvokeSafe(webClient);
            headerConfigurator?.Invoke(webClient.Headers);

            FileSystemTasks.EnsureExistingParentDirectory(path);

            await webClient.DownloadFileTaskAsync(new Uri(uri), path);
        }