【发布时间】:2015-07-24 11:05:44
【问题描述】:
如果文件夹中没有文件,如何使用 WPF 中的 OpenFileDialog 类获取文件夹路径
{
Microsoft.Win32.OpenFileDialog dlgObjDest = new Microsoft.Win32.OpenFileDialog();
dlgObjDest.Multiselect = true;
dlgObjDest.DefaultExt = ".*";
dlgObjDest.InitialDirectory = "c:";
if (dlgObjDest.ShowDialog() == true)
{
txtDestTesting.Text = System.IO.Path.GetDirectoryName(dlgObjDest.FileName);
}
}
但是当没有文件可供选择时,它无法获取文件夹路径
【问题讨论】:
标签: .net wpf c#-4.0 wpf-controls wpf-4.0