


Now let’s see how to update the ProgressBarcontrol with the method handler HttpProgressCallback. Ensure resources are released client.Dispose() inputStream.Dispose() outputStream.Dispose() Callback CopyAndCloseAsync(inputStream, outputStream) Ĩ. Open a read & write stream on the StorageFile object returned by the FileSavePicker and copy the data from the HTTP request to the StorageFile IOutputStream outputStream = await file.OpenAsync(FileAccessMode.ReadWrite) await RandomAccessStream. Read the data stream received by the HTTP request IInputStream inputStream = await () ħ. AsTask(tokenSource.Token, progressCallback) Ħ. Get the response headers var request = new HttpRequestMessage(HttpMethod.Get, new Uri()) HttpResponseMessage response = await client.SendRequestAsync(request). Initialize the HttpClient and set the progress handler var client = new HttpClient() Progress progressCallback = new Progress(httpProgressCallback) ĥ. Retrieve the FileStorage object StorageFile file = await savePicker.PickSaveFileAsync() Ĥ. Var savePicker = new ()) savePicker.SuggestedFileName = photo.Id // pre-fill file's nameģ. Create a FileSavePicker object to let the user choose the file’s destination NOTE: You need to add Pictures Library capability to give your app read & write accesses to the Pictures Library.string fileName = "test.jpg" StorageFile file = await localFolder.CreateFileAsync(newFileName) StorageFolder localFolder = // Create a new file in the app's local folder. Here is a quick sample: using System using Windows.Storage // Get the app's local folder to use as the destination folder.

But you must provide a StorageFile object to save the image to the device’s storage. NOTE: If you don’t want to use a FileSavePickerin your app, skip the first three steps.
