gpt4 book ai didi

.net - 在 wpf 中,如何使用标准对话框来选择目录

转载 作者:行者123 更新时间:2023-12-01 04:08:04 24 4
gpt4 key购买 nike

我需要用户选择一个目录,而不是一个文件。我如何使用 Microsoft.Win32.OpenFileDialog(或任何其他组件)来做到这一点?

我在 VisualStudio 2010 (.net 4.0) 中使用 WPF4.0

最佳答案

使用 System.Windows.Forms.FolderBrowserDialog :

var dlg = new System.Windows.Forms.FolderBrowserDialog();
dlg.ShowNewFolderButton = true; //if you want new folders as well
dlg.SelectedPath = someStartPath; //where to start
if( dlg.ShowDialog() == DialogResult.OK )
{
//ok user selected something
DoStuffWith( dlg.SelectedPath );
}

关于.net - 在 wpf 中,如何使用标准对话框来选择目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8064625/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com