1

I have a flipview of images, and each flipview item's image is binded to a bitmapimage which is constructed via a URI, e.g.

BitmapImage image = new BitmapImage(new URI(...));

I want the flipview of images to load only images that are selected, so in the flipview_selectionchanged event, I set the urisource of the selected image, and just make every other BitmapImage.UriSource = null as long as it's not the selected index. This works perfectly fine.

Also, whenever I instantiate an image, I type the following:

BitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;

because I want to try to access the file that is associated with that bitmapimage/uri later in my code.

And whenever a user hits this special button, the current selected image in the flipview's file is attempted to be accessed, but then I get a "UnauthorizedAccessException" for some reason.

I already tried making the current image's UriSource = null. I say GC.Collect() as well. But even after doing all of this I still get UnauthorizedAccessException.

Cherry
  • 173
  • 1
  • 10
  • possible duplicate of [UnauthorizedAccessException while saving a file](http://stackoverflow.com/questions/17000137/unauthorizedaccessexception-while-saving-a-file) – chue x Jul 11 '15 at 01:29
  • Thanks for replying, but I don't think it's a duplicate. See here where someone answered for me: [here](https://social.msdn.microsoft.com/Forums/windowsapps/en-US/bc9aa758-f211-468b-8168-a671b7a0c8b4/uwp-creating-bitmapimage-with-uri-accessing-file-from-same-uri-gives-exception?forum=wpdevelop#a6c03d5f-5bf6-48ea-8776-dadfc8eb66af). He says using Uri should work in W10 UWP, even without setting Uri to null, but when I try it it doesn't work. – Cherry Jul 14 '15 at 02:59

0 Answers0