How to use the WebClient.DownloadDataAsync() method in this context?

There is a newer DownloadDataTaskAsync method that allows you to await the result. It is simpler to read and easier to wire up by far. I’d use that…

var client = new WebClient();

var data = await client.DownloadDataTaskAsync(new Uri(imageUrl));

await outstream.WriteAsync(data, 0, data.Length);

Leave a Comment