I'm struggling with a easy problem. I want to download an image from web using this code:
WebRequest requestPic = WebRequest.Create(@"http://something.com/" + id + ".jpg");
WebResponse responsePic = await requestPic.GetResponseAsync();
Now I wanted to write the WebResponse's stream in a StorageFile (eg. create a file id.jpg in the app's storage), but I haven't found any way to achieve that. I searched the web for it, but no success - all ways incompatible Stream types and so on.
Could you please help?
That can be done using the C++ REST SDK in Windows Store Apps. It's explained by HTTP Client Tutorial.
You will need to read the response stream into a buffer then write the data to a StorageFile. THe following code shows an example:
I have found the following solution, which works and is not too complicated.