I want to open an Image from the IsolatedStorage?
The image was downloaded before and correctly written (I checked that with the Isolated Storage Explorer).
When I try to open the Image with BitmapImage(uriInIsolatedStorage) and set that as source for a Silverlight Image Control it crashs when I listen to the image failed event.
The exception said “AG_E_NETWORK_ERROR”
Does anyone has an idea?
Uri imageSource = new Uri("/cover.jpg", UriKind.Relative);
BitmapImage bi = new BitmapImage(imageSource);
bi.ImageFailed += new EventHandler<ExceptionRoutedEventArgs>(MainPage_ImageFailed);
bi.ImageOpened +=new EventHandler<RoutedEventArgs>(bi_ImageOpened);
imageCtrl.Source = bi;
Unfortunately you cannot load an image directly from isolated storage via URI. You have to open the file and do some more steps as described here or (a bit easier) here.
It boils down to:
IsolatedStorageFileStreamfor your imageBitmapImagefrom file dataBitmapImageasImagesourceThere is also an
isostore:URI scheme but it doesn’t work.