diff --git a/Form1.cs b/Form1.cs
index 5eb80d1..99fb155 100644
--- a/Form1.cs
+++ b/Form1.cs
@@ -11,6 +11,7 @@ using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;
using Newtonsoft.Json;
+using Microsoft.WindowsAPICodePack.Dialogs;
namespace MD5Create
{
@@ -49,13 +50,22 @@ namespace MD5Create
private void Choose1_Button_Click(object sender, EventArgs e)
{
- folderBrowserDialog1.Description = "请选择文件夹";
- folderBrowserDialog1.RootFolder = Environment.SpecialFolder.MyComputer;
- folderBrowserDialog1.ShowNewFolderButton = true;
- if (Path1_Box.Text.Length > 0) folderBrowserDialog1.SelectedPath = Path1_Box.Text;
- if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
+ // 使用 Windows API Code Pack 中的 CommonOpenFileDialog,开启文件夹选择模式
+ using (var dialog = new CommonOpenFileDialog())
{
- Path1_Box.Text = folderBrowserDialog1.SelectedPath;
+ dialog.Title = "请选择文件夹";
+ dialog.IsFolderPicker = true; // 文件夹选择模式
+ dialog.AllowNonFileSystemItems = false;
+
+ if (!string.IsNullOrWhiteSpace(Path1_Box.Text) && Directory.Exists(Path1_Box.Text))
+ {
+ dialog.InitialDirectory = Path1_Box.Text; // 打开到当前路径
+ }
+
+ if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
+ {
+ Path1_Box.Text = dialog.FileName; // 选择的文件夹路径
+ }
}
}
diff --git a/MD5Create.csproj b/MD5Create.csproj
index 20ad39e..d4f4448 100644
--- a/MD5Create.csproj
+++ b/MD5Create.csproj
@@ -33,6 +33,12 @@
4
+
+ packages\WindowsAPICodePack-Core.1.1.2\lib\Microsoft.WindowsAPICodePack.dll
+
+
+ packages\WindowsAPICodePack-Shell.1.1.1\lib\Microsoft.WindowsAPICodePack.Shell.dll
+
packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll
diff --git a/packages.config b/packages.config
index fef83be..f0dc6f8 100644
--- a/packages.config
+++ b/packages.config
@@ -1,4 +1,6 @@
+
+
\ No newline at end of file