【发布时间】:2017-01-15 01:08:37
【问题描述】:
我想做一个 uwp 应用程序,我想在其中使用 FileOpenPicker,但该应用程序只能在 Windows 10 上运行,而不是在 Windows 10 移动版上运行
在 Windows 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 移动版上进行测试,但我认为问题不在于 Windows 10 版本,而是我的代码...
【问题讨论】:
-
请具体说明什么不起作用。
-
我的应用程序崩溃但 Visual Studio 没有提供有关错误的信息...
-
请提供更多信息,因为我已经运行了您的代码并且效果很好。 Lumia 930,操作系统 14965
-
这是您项目中唯一的代码吗?您在生命周期事件中是否有像 EnteringBackground 或其他的东西?也许例外不符合这些规定。
-
也无法重现您的问题。您发布的代码在我的 Lumia 640、OS Build 10.0.14393.693 上运行良好。我也认为这里的问题不在您发布的代码中。可以新建一个空白项目用
FileOpenPicker进行测试,应该没有错误。
标签: c# uwp filepicker