Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Save a remote image in to Isolated Storage

Tags:

I tried using this code for download image:

void downloadImage(){
 WebClient client = new WebClient();
 client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
                client.DownloadStringAsync(new Uri("http://mysite/image.png"));

        }

void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
           //how get stream of image?? 
           PicToIsoStore(stream)
        }

        private void PicToIsoStore(Stream pic)
        {
            using (var isoStore = IsolatedStorageFile.GetUserStoreForApplication())
            {
                var bi = new BitmapImage();
                bi.SetSource(pic);
                var wb = new WriteableBitmap(bi);
                using (var isoFileStream = isoStore.CreateFile("somepic.jpg"))
                {
                    var width = wb.PixelWidth;
                    var height = wb.PixelHeight;
                    Extensions.SaveJpeg(wb, isoFileStream, width, height, 0, 100);
                }
            }
        }

The problem is: how get the stream of image?

Thank!