简体   繁体   English

FolderPicker在UWP Windows 10应用程序(移动)中不起作用

[英]FolderPicker does not work in UWP Windows 10 app (mobile)

I am developing an UWP Windows 10 app. 我正在开发一个UWP Windows 10应用程序。 Given following code sample.... 给出以下代码示例....

using Windows.Storage;
using Windows.Storage.Pickers;

FolderPicker picker = new FolderPicker() { SuggestedStartLocation = PickerLocationId.PicturesLibrary };

picker.FileTypeFilter.Add(".jpg");
picker.FileTypeFilter.Add(".jpeg");
StorageFolder folder = await picker.PickSingleFolderAsync();

if (folder != null) { ... work ... }

... everything works fine on Desktop . ... 桌面上的一切正常

On Mobile, unfortunately (build 10.0.10549), the first time I invoke the method, a system-dialog appears where I can choose "My device" as a single option. 在Mobile上,不幸的是 (build 10.0.10549),我第一次调用该方法时,会出现一个系统对话框,我可以选择“我的设备”作为单个选项。 Clicking this option results in a start of the system-file-explorer-app followed by an immediate close/crash/whatever of that app. 单击此选项将导致system-file-explorer-app启动,然后立即关闭/崩溃/该应用程序的任何内容。 So I find myself back in my own app with folder == null . 所以我发现自己回到了我自己的应用程序, folder == null When I now try to run the given snippet again, PickSingleFolderAsync() throws an UnauthorizedAccessException ("Access is denied"). 当我现在尝试再次运行给定的片段时, PickSingleFolderAsync()会抛出UnauthorizedAccessException(“访问被拒绝”)。 However, if I place a breakpoint on the line with PickSingleFolderAsync() , the app does not crash but like in the first try, the file-explorer app returns immediately again, without any folder. 但是,如果我在PickSingleFolderAsync()的行上放置一个断点,应用程序不会崩溃,但在第一次尝试时,文件浏览器应用程序会立即再次返回,没有任何文件夹。

Reference zu method: https://msdn.microsoft.com/de-de/library/windows/apps/windows.storage.pickers.folderpicker.picksinglefolderasync 参考zu方法: https//msdn.microsoft.com/de-de/library/windows/apps/windows.storage.pickers.folderpicker.picksinglefolderasync

It seems that the Win10 mobile build 10572 fix the error. 似乎Win10移动版本10572修复了错误。 I have experienced the same folderpicker issue with build 10549, but after updating to 10572, it works. 我遇到了与build 10549相同的folderpicker问题,但在更新到10572后,它可以工作。

Added 05/Nov/2015 - App deployment from VS to Win10M devices works well with VS2015 Update1 RC + Win10M 10581. You may see the error messagebox when you tried to 'Run without debug', but deploy itself works. 已添加05 / Nov / 2015 - 从VS到Win10M设备的应用程序部署与VS2015 Update1 RC + Win10M 10581配合良好。当您尝试“无需调试运行”时,您可能会看到错误消息框,但部署本身有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM