你好,
欢迎来到微软问答!
FileOpenPicker、FileSavePicker 和FolderPicker API 需要与它们关联的HWND,以便它们知道哪个窗口是它们需要显示的目标窗口。 如果您尝试在WinUI3应用程序中使用FolderPicker,则需要获取当前的HWND并在选择器上设置HWND。
var Picker = new FolderPicker();
// Get the current window's HWND by passing in the Window object
var hwnd = WinRT.Interop.WindowNative.GetWindowHandle(this);
// Associate the HWND with the file picker
WinRT.Interop.InitializeWithWindow.Initialize(Picker, hwnd);
Picker.FileTypeFilter.Add("*");
var folder = await Picker.PickSingleFolderAsync();
谢谢
如果答案是正确的,请点击“接受答案”并点赞。 如果您对此答案还有其他疑问,请点击“评论”。 注意:如果您想收到该主题的相关电子邮件通知,请按照我们文档中的步骤启用电子邮件通知。