I have a program in which I want to download an image from internet. I followed this tutorial: How to download and store an image using Windows.Web.Http?.
This was my source code:
Uri uri = new Uri(CoverImage);
string filename = BookNameTextBox.Text + ".jpg";
StorageFile destinationFile = await ApplicationData.Current.LocalFolder.CreateFileAsync(filename);
HttpClient client = new HttpClient();
var buffer = await client.GetBufferAsync(uri);
StorageFile photo = await ApplicationData.Current.LocalFolder.GetFileAsync(CoverImage);
The program does not compile. It says, "HttpClient does not contain a definition for 'GetBufferAsync' ". While googling, I found this article https://learn.microsoft.com/en-us/uwp/api/windows.web.http.httpclient.getbufferasync according to which the method exists. I don't know what to do.
The irony is I actually use HttpClient in another file and it works fine. This is that part:
var http = new HttpClient();
string url = "https://www.googleapis.com/books/v1/volumes?q=" + title.Replace(' ', '+') + "&fields = items(volumeInfo(title, authors, publisher)), items/";
var response = await http.GetAsync(url);
var result = await response.Content.ReadAsStringAsync();