0

I want do an uwp app where I want use FileOpenPicker but the app work only on windows 10 and not on windows 10 mobile

On windows 10 mobile my app crash...and the exception message is: "Element not found. (Exception from HRESULT: 0x80070490)"

This is my code:

        FileOpenPicker openPicker = new FileOpenPicker();
        openPicker.ViewMode = PickerViewMode.Thumbnail;
        openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
        openPicker.FileTypeFilter.Add(".jpg");
        openPicker.FileTypeFilter.Add(".jpeg");
        openPicker.FileTypeFilter.Add(".png");

        StorageFile file = await openPicker.PickSingleFileAsync();

        if (file != null)

        {

            var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);

            var image = new BitmapImage();

            ImageBrush ib = new ImageBrush();
            ib.ImageSource = image;

            image.SetSource(stream);

            var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
            var filePath = file.Path;
            localSettings.Values["monimage"] = filePath;

            set.Background = new ImageBrush { ImageSource = image, Stretch = Stretch.UniformToFill };

        }

        else

        {

            //

        }

I have tested my app on windows 10 mobile 10.0.14393.693 I have not the possibility to test on others windows 10 mobile version but I think the problem is not the windows 10 version but my code...

sami54
  • 123
  • 1
  • 13
  • Please be specific what doesn't work. – Raymond Chen Jan 15 '17 at 01:36
  • My app crash but visual studio don't give information about the error ... – sami54 Jan 15 '17 at 02:04
  • 1
    please provide more info, because I've run your code and it works good. Lumia 930, OS 14965 – Andrii Krupka Jan 15 '17 at 02:11
  • What is the exception passed to the unhandled exception handler? (This is basic debugging you should do before asking the question.) – Raymond Chen Jan 15 '17 at 02:48
  • I am sorry I am a beginner... the exception message is: "Element not found. (Exception from HRESULT: 0x80070490)" when I put a try catch on the part of code I put in my question – sami54 Jan 15 '17 at 03:05
  • 1
    Is this the only code in your project? Do you have something in lifecycle events like *EnteringBackground* or other? Maybe exception is not according to those lines. – Romasz Jan 15 '17 at 11:47
  • this is the only code who have a problem, when I click on a button this code is play and I have an error – sami54 Jan 15 '17 at 14:04
  • 1
    Also can't reproduce your issue. The code you've posted works well on my Lumia 640, OS Build 10.0.14393.693. I also think the problem here is not in the code you've posted. You can create a new blank project to test with the `FileOpenPicker`, there should be no error. – Jay Zuo Jan 16 '17 at 07:31

1 Answers1

0

I solved myself the problem, I tested the others app of the store who use FileOpenPicker and they all have the same error so I reinstalled windows 10 mobile and all work well now :)

sami54
  • 123
  • 1
  • 13