使用Windows 10 UWP应用程序中的文件夹选择器允许用户选择文件夹:
var folderPicker = new Windows.Storage.Pickers.FolderPicker();
folderPicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Desktop;
folderPicker.FileTypeFilter.Add("*");
Windows.Storage.StorageFolder folder = await folderPicker.PickSingleFolderAsync();
我可以通过以下方式获取子文件夹列表:
Task<IReadOnlyList<StorageFolder>> subFolders = SubFolders(folder);
private async Task<IReadOnlyList<StorageFolder>> SubFolders(StorageFolder folder)
{
IReadOnlyList<StorageFolder> folderList = await folder.GetFoldersAsync();
return folderList;
}
当我遍历列表时:
foreach (StorageFolder sf in subFolders)
{
StorageFile f = await sf.GetFileAsync("something.dat");
}
它在GetFileAsync上崩溃,这是安全设计还是我在做些傻事?
我输出视图的所有内容是:
线程0x2690已退出,代码为0(0x0)。
有人帮忙吗?