WPF 中的OpenFileDialog和 OpenFolderDialog

时间:2023-03-09 07:11:04
WPF 中的OpenFileDialog和 OpenFolderDialog

OpenFolderDialog:

            using (var dialog = new System.Windows.Forms.FolderBrowserDialog() { SelectedPath = destinationApp, ShowNewFolderButton = true })
{
System.Windows.Forms.DialogResult result = dialog.ShowDialog();
if (result == System.Windows.Forms.DialogResult.OK)
{
//TODO: use dialog.SelectedPath;
}
}

OpenFileDialog:

            using (var dialog = new System.Windows.Forms.OpenFileDialog())
{
System.Windows.Forms.DialogResult result = dialog.ShowDialog();
if (result == System.Windows.Forms.DialogResult.OK)
{
//TODO: use dialog.FileName, FileNames;
}
}