I\'m trying to download file with Xamarin, but receive an error massage:
An exception occurred during a WebClient request. I thing that the problem is wit
var httpClientHandler = new HttpClientHandler
{
AllowAutoRedirect = false,
....
};
var httpClient = new System.Net.Http.HttpClient(httpClientHandler)
{
MaxResponseContentBufferSize = 5000000,
...
};
var uri = new Uri("http://x.com");
using (var response = await httpClient.GetAsync(uri))
{
if (!response.IsSuccessStatusCode)
throw new HttpRequestException($"URL {uri} not loaded. {response.StatusCode}");
var str = await response.Content.ReadAsStringAsync();
// ...
}
You only created a folder, but didn't create a file for download file, you can just modify your code webClient.DownloadFileAsync(new Uri("http://www.dada-data.net/uploads/image/hausmann_abcd.jpg"), folder);
for example like this:
webClient.DownloadFileAsync(new Uri("http://www.dada-data.net/uploads/image/hausmann_abcd.jpg"), folder + "/abc.jpg");