Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all articles
Browse latest Browse all 935

What's event to use processbar when downloading?Of couse, Using this code.

$
0
0
 {

            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();
        }


Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>