Windows 8.1应用程序中的文件夹选取器崩溃

时间:2015-01-26 06:34:44

标签: c# windows-8.1

在我的Windows 8.1中我试图显示文件夹选择器,但它以崩溃结束(App.g.i.cs文件中的调试器中断)。

这是我用于文件夹选择器的代码:

FolderPicker openFP = new FolderPicker();
openFP.ViewMode = PickerViewMode.Thumbnail;
openFP.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
StorageFolder SF = await openFP.PickSingleFolderAsync();          StorageApplicationPermissions.FutureAccessList.AddOrReplace("PickedFolderToken", SF);
this.Frame.Navigate(typeof(MainPage), SF.Name); 

请给我任何解决方案

1 个答案:

答案 0 :(得分:1)

我通过在代码中添加过滤器类型来获取文件夹选择器 代码:

FolderPicker openFP = new FolderPicker();
openFP.ViewMode = PickerViewMode.Thumbnail;
openFP.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
openFP.FileTypeFilter.Add(".jpeg");
openFP.FileTypeFilter.Add(".gif");
openFP.FileTypeFilter.Add(".png");
StorageFolder SF = await openFP.PickSingleFolderAsync();    StorageApplicationPermissions.FutureAccessList.AddOrReplace("PickedFolderToken", SF);
this.Frame.Navigate(typeof(MainPage), SF.Name);