选择文件夹时可以再导航来输入路径
This commit is contained in:
22
Form1.cs
22
Form1.cs
@@ -11,6 +11,7 @@ using System.Threading.Tasks;
|
|||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using Microsoft.WindowsAPICodePack.Dialogs;
|
||||||
|
|
||||||
namespace MD5Create
|
namespace MD5Create
|
||||||
{
|
{
|
||||||
@@ -49,13 +50,22 @@ namespace MD5Create
|
|||||||
|
|
||||||
private void Choose1_Button_Click(object sender, EventArgs e)
|
private void Choose1_Button_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
folderBrowserDialog1.Description = "请选择文件夹";
|
// 使用 Windows API Code Pack 中的 CommonOpenFileDialog,开启文件夹选择模式
|
||||||
folderBrowserDialog1.RootFolder = Environment.SpecialFolder.MyComputer;
|
using (var dialog = new CommonOpenFileDialog())
|
||||||
folderBrowserDialog1.ShowNewFolderButton = true;
|
|
||||||
if (Path1_Box.Text.Length > 0) folderBrowserDialog1.SelectedPath = Path1_Box.Text;
|
|
||||||
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
{
|
||||||
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; // 选择的文件夹路径
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -33,6 +33,12 @@
|
|||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="Microsoft.WindowsAPICodePack, Version=1.1.2.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>packages\WindowsAPICodePack-Core.1.1.2\lib\Microsoft.WindowsAPICodePack.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.WindowsAPICodePack.Shell, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>packages\WindowsAPICodePack-Shell.1.1.1\lib\Microsoft.WindowsAPICodePack.Shell.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
<HintPath>packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
<HintPath>packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
@@ -1,4 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net472" />
|
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net472" />
|
||||||
|
<package id="WindowsAPICodePack-Core" version="1.1.2" targetFramework="net472" />
|
||||||
|
<package id="WindowsAPICodePack-Shell" version="1.1.1" targetFramework="net472" />
|
||||||
</packages>
|
</packages>
|
Reference in New Issue
Block a user