2017-01-15 24 views
0

我想要做一個UWP應用程序,我想用FileOpenPicker但只適用於Windows 10,而不是在Windows 10移動FileOpenPicker窗口10移動

在窗口10移動我的應用程序崩潰...和異常消息應用工作是:「找不到元素(從HRESULT異常:0x80070490)。」

這是我的代碼:

 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 

     { 

      // 

     } 

我已經測試我的應用程序在Windows 10移動10.0.14393.693 我沒有可能性測試別人的Windows 10手機版本,但我thi問題不是Windows 10的版本,但我的代碼...

+0

請具體什麼不行。 –

+0

我的應用程序崩潰,但視覺工作室不提供有關錯誤的信息... – sami54

+1

請提供更多信息,因爲我已經運行你的代碼,它的效果很好。 Lumia 930,OS 14965 –

回答

0

我解決了自己的問題,我測試了商店的其他應用程序使用FileOpenPicker,他們都有相同的錯誤,所以我重新安裝了Windows 10的移動和現在一切正常:)