You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

UWP中如何调出目标样式的文件夹选择对话框?

解决FolderPicker显示文件选择对话框样式的问题

你当前弹出的对话框之所以类似文件选择框,是因为代码中添加了folderPicker.FileTypeFilter.Add("*");这行配置——它会让对话框显示所有类型的文件,从而改变了FolderPicker原本仅显示文件夹的默认行为。

修改后的代码

只需移除那行文件类型过滤代码即可:

private async void OpenFolder_Clicked()
{
    var folderPicker = new Windows.Storage.Pickers.FolderPicker
    {
        SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Desktop
    };

    Windows.Storage.StorageFolder folder = await folderPicker.PickSingleFolderAsync();
    if (folder != null)
    {
        // do something
    }
}

修改后,FolderPicker会恢复默认的文件夹选择模式,对话框只会展示文件夹目录,和你预期的样式一致。

内容的提问来源于stack exchange,提问作者ricky rocky

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.11 19:43:14