{ try { var url = ((BitmapImage)img_background.Source); var SourceUrl = url.UriSource; HttpClient http = new HttpClient(); Stream resp = await http.GetStreamAsync(SourceUrl); //greate images file in your picture library //Here we will split for string to give name images file string text = SourceUrl.ToString(); string[] arr = text.Split('/'); var storgefile = await KnownFolders.PicturesLibrary.CreateFileAsync(arr[arr.Length-1], CreationCollisionOption.ReplaceExisting); using (var storgestream = await storgefile.OpenAsync(FileAccessMode.ReadWrite)) { await RandomAccessStream.CopyAndCloseAsync(resp.AsInputStream(), storgestream.GetOutputStreamAt(0)); } } catch (Exception ex) { txterror.Text = ex.Message; } } private void Button_Click(object sender, RoutedEventArgs e) { img_background.Source = new BitmapImage(new Uri("https://www.google.com/images/srpr/logo11w.png")); download_images(); }
↧
What's event to use processbar when downloading?Of couse, Using this code.
↧