Created
March 24, 2020 12:51
-
-
Save Mogikan/03fe4a4cf53f9473657d25c367a90d1d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public MainPage() | |
{ | |
this.InitializeComponent(); | |
Loaded += MainPage_Loaded; | |
} | |
private async void MainPage_Loaded(object sender, RoutedEventArgs e) | |
{ | |
string url = "https://p.bigstockphoto.com/GeFvQkBbSLaMdpKXF1Zv_bigstock-Aerial-View-Of-Blue-Lakes-And--227291596.jpg"; | |
var file = await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFileAsync("photo.jpg"); | |
HttpRequestMessage req = new HttpRequestMessage(HttpMethod.Get, url); | |
var client = new HttpClient(); | |
HttpResponseMessage response = await client.SendAsync(req); | |
using (Stream responseStream = await response.Content.ReadAsStreamAsync()) | |
{ | |
var fileStream = new FileStream(file.Path, FileMode.Open); | |
await responseStream.CopyToAsync(fileStream); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment