![]() Create a new subfolder in the current folder. StorageFolder localFolder = .LocalFolder || mediaType.IndexOf("jpeg", StringComparison.OrdinalIgnoreCase) >= 0)Įlse if (mediaType.IndexOf("png", StringComparison.OrdinalIgnoreCase) >= 0)Įlse if (mediaType.IndexOf("gif", StringComparison.OrdinalIgnoreCase) >= 0)Įlse if (mediaType.IndexOf("bmp", StringComparison.OrdinalIgnoreCase) >= 0) ![]() If (mediaType.IndexOf("jpg", StringComparison.OrdinalIgnoreCase) >= 0 Using (var response = await client.GetAsync(uri, cancellationTokenSource.Token)) Var uri = new Uri(WebUtility.HtmlDecode(imageUrl)) Using (var cancellationTokenSource = new CancellationTokenSource(50000)) Private async void Button_Click(object sender, RoutedEventArgs e) Public sealed partial class MainPage : Page / An empty page that can be used on its own or navigated to within a Frame. The Blank Page item template is documented at Just paste the image URL link and press the download button. Made a demo UWP application for downloading an image file. Using (IInputStream inputStream = await ())īitmapImage.SetSource(inputStream.AsStreamForRead()) ĭebug.WriteLine("Failed to load the image: ", ex.Message) ![]() Using (var response = await client.GetAsync(uri)) Using (HttpClient client = new HttpClient()) Public async static Task LoadImage(Uri uri)īitmapImage bitmapImage = new BitmapImage() As the comment over there states, this guy must be the only person in the world who knows about ! using System I should note that this question from MSDN helped me out a lot, so thanks to that person. There is not much documentation around and a lot of the examples online use old mechanisms like ReadAllBytesAsync which are not available with this HttpClient.
0 Comments
Leave a Reply. |