【导图】:
实现效果:
选择文件夹
打开图片文件选择:
打开图片选择:
private string openFileDialog() { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "图片|*.jpg;*.png;*.bmp"; openFileDialog.DefaultExt = ".png"; if (openFileDialog.ShowDialog() == true) { return openFileDialog.FileName; } return string.Empty; }
打开文件夹选择:
1.下载NuGet包
2.
using Microsoft.WindowsAPICodePack.Dialogs;// 要using private string openFolderDialog() { var dlg = new CommonOpenFileDialog(); dlg.IsFolderPicker = true; if (dlg.ShowDialog() == CommonFileDialogResult.Ok) { var folder = dlg.FileName; return folder; } return string.Empty; }
标签:dlg,string,C#,文件夹,openFileDialog,return,WPF,打开 From: https://www.cnblogs.com/moon-stars/p/18474307