Commit 7cf335ea authored by 罗显健's avatar 罗显健

【编号:16731】增加文件搜索工具

parent 02fce21a
...@@ -19,6 +19,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebKit", "WebKit\WebKit.csp ...@@ -19,6 +19,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebKit", "WebKit\WebKit.csp
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNetVersionChecker", "DotNetVersionChecker\DotNetVersionChecker.csproj", "{3AA9B489-83C4-4530-8B38-833726D203E7}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNetVersionChecker", "DotNetVersionChecker\DotNetVersionChecker.csproj", "{3AA9B489-83C4-4530-8B38-833726D203E7}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsSearch", "WindowsSearch\WindowsSearch.csproj", "{0A591ECF-134D-40FD-A8E4-57D8A70FC309}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
...@@ -125,6 +127,18 @@ Global ...@@ -125,6 +127,18 @@ Global
{3AA9B489-83C4-4530-8B38-833726D203E7}.Release|x64.Build.0 = Release|Any CPU {3AA9B489-83C4-4530-8B38-833726D203E7}.Release|x64.Build.0 = Release|Any CPU
{3AA9B489-83C4-4530-8B38-833726D203E7}.Release|x86.ActiveCfg = Release|Any CPU {3AA9B489-83C4-4530-8B38-833726D203E7}.Release|x86.ActiveCfg = Release|Any CPU
{3AA9B489-83C4-4530-8B38-833726D203E7}.Release|x86.Build.0 = Release|Any CPU {3AA9B489-83C4-4530-8B38-833726D203E7}.Release|x86.Build.0 = Release|Any CPU
{0A591ECF-134D-40FD-A8E4-57D8A70FC309}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0A591ECF-134D-40FD-A8E4-57D8A70FC309}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0A591ECF-134D-40FD-A8E4-57D8A70FC309}.Debug|x64.ActiveCfg = Debug|x64
{0A591ECF-134D-40FD-A8E4-57D8A70FC309}.Debug|x64.Build.0 = Debug|x64
{0A591ECF-134D-40FD-A8E4-57D8A70FC309}.Debug|x86.ActiveCfg = Debug|x86
{0A591ECF-134D-40FD-A8E4-57D8A70FC309}.Debug|x86.Build.0 = Debug|x86
{0A591ECF-134D-40FD-A8E4-57D8A70FC309}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0A591ECF-134D-40FD-A8E4-57D8A70FC309}.Release|Any CPU.Build.0 = Release|Any CPU
{0A591ECF-134D-40FD-A8E4-57D8A70FC309}.Release|x64.ActiveCfg = Release|x64
{0A591ECF-134D-40FD-A8E4-57D8A70FC309}.Release|x64.Build.0 = Release|x64
{0A591ECF-134D-40FD-A8E4-57D8A70FC309}.Release|x86.ActiveCfg = Release|x86
{0A591ECF-134D-40FD-A8E4-57D8A70FC309}.Release|x86.Build.0 = Release|x86
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
......
...@@ -575,6 +575,10 @@ ...@@ -575,6 +575,10 @@
<Project>{5abcd19a-7a28-479c-bcae-0ad7f1a4feb0}</Project> <Project>{5abcd19a-7a28-479c-bcae-0ad7f1a4feb0}</Project>
<Name>UpdateExecuter</Name> <Name>UpdateExecuter</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\WindowsSearch\WindowsSearch.csproj">
<Project>{0a591ecf-134d-40fd-a8e4-57d8a70fc309}</Project>
<Name>WindowsSearch</Name>
</ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="Resources\分析.png" /> <None Include="Resources\分析.png" />
......
...@@ -44,6 +44,7 @@ namespace Tools ...@@ -44,6 +44,7 @@ namespace Tools
this.CreateModule(Tools_uni, typeof(UI.wDbLinkMngr), "共享信息", "tr:客户数据库及远程桌面信息"), this.CreateModule(Tools_uni, typeof(UI.wDbLinkMngr), "共享信息", "tr:客户数据库及远程桌面信息"),
this.CreateModule(Tools_uni, typeof(UI.wTaskBoard), "任务看板", "tr:任务看板的简易化工具,免除翻页困扰"), this.CreateModule(Tools_uni, typeof(UI.wTaskBoard), "任务看板", "tr:任务看板的简易化工具,免除翻页困扰"),
this.CreateModule(Tools_uni, typeof(UI.wLoginPwd), "密码解析", "tr:用于登陆密码的解密加密"), this.CreateModule(Tools_uni, typeof(UI.wLoginPwd), "密码解析", "tr:用于登陆密码的解密加密"),
this.CreateModule(Tools_uni, typeof(WindowsSearch.FrmSearch), "文件搜索", "lxj:用于搜索文件内容"),
//------------------------------- //-------------------------------
this.CreateModule(Tools_imp, typeof(UpdateExecuter.frmMain), "更新执行工具", "lxj:用于客户更新和执行SQL脚本"), this.CreateModule(Tools_imp, typeof(UpdateExecuter.frmMain), "更新执行工具", "lxj:用于客户更新和执行SQL脚本"),
this.CreateModule(Tools_imp, typeof(UI.wEmptyTable), "清空表", "tr:输入主表、自动清空关联表的工具"), this.CreateModule(Tools_imp, typeof(UI.wEmptyTable), "清空表", "tr:输入主表、自动清空关联表的工具"),
......
namespace WindowsSearch
{
partial class FrmSearch
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmSearch));
this.label1 = new System.Windows.Forms.Label();
this.txtFilePath = new System.Windows.Forms.TextBox();
this.btnSelectPath = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.txtSearchText = new System.Windows.Forms.TextBox();
this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
this.btnSearch = new System.Windows.Forms.Button();
this.pnlTop = new System.Windows.Forms.Panel();
this.pnlSearchType = new System.Windows.Forms.Panel();
this.ckbAll = new System.Windows.Forms.CheckBox();
this.ckbCSharp = new System.Windows.Forms.CheckBox();
this.ckbText = new System.Windows.Forms.CheckBox();
this.ckbSql = new System.Windows.Forms.CheckBox();
this.lblStatus = new System.Windows.Forms.Label();
this.lisBoxShow = new System.Windows.Forms.ListBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.pnlStatus = new System.Windows.Forms.Panel();
this.progressBar1 = new System.Windows.Forms.ProgressBar();
this.pnlBottom = new System.Windows.Forms.Panel();
this.pnlTop.SuspendLayout();
this.pnlSearchType.SuspendLayout();
this.groupBox1.SuspendLayout();
this.pnlStatus.SuspendLayout();
this.pnlBottom.SuspendLayout();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("宋体", 9F);
this.label1.Location = new System.Drawing.Point(8, 14);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(53, 12);
this.label1.TabIndex = 0;
this.label1.Text = "搜索路径";
//
// txtFilePath
//
this.txtFilePath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtFilePath.Location = new System.Drawing.Point(65, 10);
this.txtFilePath.Name = "txtFilePath";
this.txtFilePath.Size = new System.Drawing.Size(396, 21);
this.txtFilePath.TabIndex = 1;
//
// btnSelectPath
//
this.btnSelectPath.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnSelectPath.Location = new System.Drawing.Point(481, 10);
this.btnSelectPath.Name = "btnSelectPath";
this.btnSelectPath.Size = new System.Drawing.Size(75, 23);
this.btnSelectPath.TabIndex = 2;
this.btnSelectPath.Text = "选择...";
this.btnSelectPath.UseVisualStyleBackColor = true;
this.btnSelectPath.Click += new System.EventHandler(this.btnSelectPath_Click);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(8, 47);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(53, 12);
this.label2.TabIndex = 3;
this.label2.Text = "搜索内容";
//
// txtSearchText
//
this.txtSearchText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtSearchText.Location = new System.Drawing.Point(65, 44);
this.txtSearchText.Name = "txtSearchText";
this.txtSearchText.Size = new System.Drawing.Size(396, 21);
this.txtSearchText.TabIndex = 4;
//
// btnSearch
//
this.btnSearch.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnSearch.Location = new System.Drawing.Point(481, 44);
this.btnSearch.Name = "btnSearch";
this.btnSearch.Size = new System.Drawing.Size(75, 23);
this.btnSearch.TabIndex = 7;
this.btnSearch.Text = "搜索";
this.btnSearch.UseVisualStyleBackColor = true;
//
// pnlTop
//
this.pnlTop.Controls.Add(this.pnlSearchType);
this.pnlTop.Controls.Add(this.btnSearch);
this.pnlTop.Controls.Add(this.label1);
this.pnlTop.Controls.Add(this.txtFilePath);
this.pnlTop.Controls.Add(this.btnSelectPath);
this.pnlTop.Controls.Add(this.label2);
this.pnlTop.Controls.Add(this.txtSearchText);
this.pnlTop.Dock = System.Windows.Forms.DockStyle.Top;
this.pnlTop.Location = new System.Drawing.Point(0, 0);
this.pnlTop.Name = "pnlTop";
this.pnlTop.Size = new System.Drawing.Size(857, 74);
this.pnlTop.TabIndex = 10;
//
// pnlSearchType
//
this.pnlSearchType.Controls.Add(this.ckbAll);
this.pnlSearchType.Controls.Add(this.ckbCSharp);
this.pnlSearchType.Controls.Add(this.ckbText);
this.pnlSearchType.Controls.Add(this.ckbSql);
this.pnlSearchType.Dock = System.Windows.Forms.DockStyle.Right;
this.pnlSearchType.Location = new System.Drawing.Point(588, 0);
this.pnlSearchType.Name = "pnlSearchType";
this.pnlSearchType.Size = new System.Drawing.Size(269, 74);
this.pnlSearchType.TabIndex = 9;
//
// ckbAll
//
this.ckbAll.Location = new System.Drawing.Point(152, 8);
this.ckbAll.Name = "ckbAll";
this.ckbAll.Size = new System.Drawing.Size(85, 18);
this.ckbAll.TabIndex = 11;
this.ckbAll.Text = "所有类型";
this.ckbAll.UseVisualStyleBackColor = true;
this.ckbAll.CheckedChanged += new System.EventHandler(this.ckbFileType_CheckedChanged);
//
// ckbCSharp
//
this.ckbCSharp.Location = new System.Drawing.Point(6, 54);
this.ckbCSharp.Name = "ckbCSharp";
this.ckbCSharp.Size = new System.Drawing.Size(255, 18);
this.ckbCSharp.TabIndex = 10;
this.ckbCSharp.Text = "ckbCSharp";
this.ckbCSharp.UseVisualStyleBackColor = true;
this.ckbCSharp.CheckedChanged += new System.EventHandler(this.ckbFileType_CheckedChanged);
//
// ckbText
//
this.ckbText.Location = new System.Drawing.Point(6, 8);
this.ckbText.Name = "ckbText";
this.ckbText.Size = new System.Drawing.Size(85, 18);
this.ckbText.TabIndex = 9;
this.ckbText.Text = "ckbText";
this.ckbText.UseVisualStyleBackColor = true;
this.ckbText.CheckedChanged += new System.EventHandler(this.ckbFileType_CheckedChanged);
//
// ckbSql
//
this.ckbSql.Location = new System.Drawing.Point(6, 32);
this.ckbSql.Name = "ckbSql";
this.ckbSql.Size = new System.Drawing.Size(255, 18);
this.ckbSql.TabIndex = 8;
this.ckbSql.Text = "ckbSql";
this.ckbSql.UseVisualStyleBackColor = true;
this.ckbSql.CheckedChanged += new System.EventHandler(this.ckbFileType_CheckedChanged);
//
// lblStatus
//
this.lblStatus.AutoSize = true;
this.lblStatus.Dock = System.Windows.Forms.DockStyle.Right;
this.lblStatus.Location = new System.Drawing.Point(846, 0);
this.lblStatus.Name = "lblStatus";
this.lblStatus.Size = new System.Drawing.Size(11, 12);
this.lblStatus.TabIndex = 6;
this.lblStatus.Text = ".";
//
// lisBoxShow
//
this.lisBoxShow.Dock = System.Windows.Forms.DockStyle.Fill;
this.lisBoxShow.FormattingEnabled = true;
this.lisBoxShow.ItemHeight = 12;
this.lisBoxShow.Location = new System.Drawing.Point(0, 14);
this.lisBoxShow.Margin = new System.Windows.Forms.Padding(0);
this.lisBoxShow.Name = "lisBoxShow";
this.lisBoxShow.Size = new System.Drawing.Size(857, 385);
this.lisBoxShow.TabIndex = 8;
this.lisBoxShow.DoubleClick += new System.EventHandler(this.lisBoxShow_DoubleClick);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.lisBoxShow);
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.groupBox1.Location = new System.Drawing.Point(0, 74);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Padding = new System.Windows.Forms.Padding(0);
this.groupBox1.Size = new System.Drawing.Size(857, 399);
this.groupBox1.TabIndex = 11;
this.groupBox1.TabStop = false;
//
// pnlStatus
//
this.pnlStatus.Controls.Add(this.lblStatus);
this.pnlStatus.Dock = System.Windows.Forms.DockStyle.Bottom;
this.pnlStatus.Location = new System.Drawing.Point(0, 473);
this.pnlStatus.Name = "pnlStatus";
this.pnlStatus.Size = new System.Drawing.Size(857, 15);
this.pnlStatus.TabIndex = 9;
//
// progressBar1
//
this.progressBar1.Dock = System.Windows.Forms.DockStyle.Fill;
this.progressBar1.Location = new System.Drawing.Point(0, 0);
this.progressBar1.Name = "progressBar1";
this.progressBar1.Size = new System.Drawing.Size(857, 3);
this.progressBar1.TabIndex = 7;
//
// pnlBottom
//
this.pnlBottom.Controls.Add(this.progressBar1);
this.pnlBottom.Dock = System.Windows.Forms.DockStyle.Bottom;
this.pnlBottom.Location = new System.Drawing.Point(0, 488);
this.pnlBottom.Name = "pnlBottom";
this.pnlBottom.Size = new System.Drawing.Size(857, 3);
this.pnlBottom.TabIndex = 9;
//
// FrmSearch
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(857, 491);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.pnlStatus);
this.Controls.Add(this.pnlBottom);
this.Controls.Add(this.pnlTop);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "FrmSearch";
this.Text = "文件搜索";
this.pnlTop.ResumeLayout(false);
this.pnlTop.PerformLayout();
this.pnlSearchType.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
this.pnlStatus.ResumeLayout(false);
this.pnlStatus.PerformLayout();
this.pnlBottom.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox txtFilePath;
private System.Windows.Forms.Button btnSelectPath;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox txtSearchText;
private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1;
private System.Windows.Forms.Button btnSearch;
private System.Windows.Forms.Panel pnlTop;
private System.Windows.Forms.Label lblStatus;
private System.Windows.Forms.ListBox lisBoxShow;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.CheckBox ckbSql;
private System.Windows.Forms.CheckBox ckbText;
private System.Windows.Forms.CheckBox ckbCSharp;
private System.Windows.Forms.Panel pnlStatus;
private System.Windows.Forms.ProgressBar progressBar1;
private System.Windows.Forms.Panel pnlSearchType;
private System.Windows.Forms.Panel pnlBottom;
private System.Windows.Forms.CheckBox ckbAll;
}
}
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsSearch
{
/*
* 1.使用异步搜索,在界面不假死的前提下,尽可能快的找到结果
* 2.搜索过程进度表示、搜索目录总文件数、当前搜了多少文件,动态实时反馈。 Ui操作性能影响很大、甚至非常大。
*
* 下一步考虑增加搜索数据库。
*
*/
public partial class FrmSearch : Form
{
private readonly ToolTip toolTip = new ToolTip();
private List<string> searchTypes = new List<string>();
private List<KeyValuePair<string, Regex>> kvpSearchTypes = new List<KeyValuePair<string, Regex>>();
public FrmSearch()
{
InitializeComponent();
this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
InitSearchType();
InitContextMenu();
}
#region 初始化
/// <summary>
/// 初始化搜索类型
/// </summary>
private void InitSearchType()
{
SetType(ckbText, "*.txt; *.md", true, "记事本、MarkDown");
SetType(ckbSql, "*.sql", true, "sql脚本文件");
SetType(ckbCSharp, "*.cs;*.vb;*.resx;*.xsd;*.wsdl;*.htm;*.html;*.aspx;*.ascx;*.asmx;*.svc;*.asax;*.config;*.asp;*.asa;*.cshtml;*.vbhtml;*.razor;*.css;*.xml", false, "常规程序文件类型");
SetType(ckbAll, "*.*", false, "忽而文件类型,搜所有文件");
SetSearchType();
}
/// <summary>
/// 初始化右键菜单
/// </summary>
private void InitContextMenu()
{
// 创建右键菜单
ContextMenuStrip contextMenu = new ContextMenuStrip();
// 添加“打开”菜单项
ToolStripMenuItem openMenuItem = new ToolStripMenuItem("打开(默认程序)");
openMenuItem.Click += OpenMenuItem_Click;
contextMenu.Items.Add(openMenuItem);
// 添加“选择打开方式”菜单项
ToolStripMenuItem chooseOpenWithMenuItem = new ToolStripMenuItem("选择打开方式");
chooseOpenWithMenuItem.Click += ChooseOpenWithMenuItem_Click;
contextMenu.Items.Add(chooseOpenWithMenuItem);
// 将右键菜单绑定到 ListBox
lisBoxShow.ContextMenuStrip = contextMenu;
}
#endregion
#region 右键菜单事件
/// <summary>
/// 打开(默认程序)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OpenMenuItem_Click(object sender, EventArgs e)
{
string selectedFilePath = GetSelectedFilePath();
if (!string.IsNullOrEmpty(selectedFilePath))
{
// 使用默认程序打开文件
Process.Start(new ProcessStartInfo(selectedFilePath) { UseShellExecute = true });
}
}
/// <summary>
/// 选择打开方式
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ChooseOpenWithMenuItem_Click(object sender, EventArgs e)
{
string selectedFilePath = GetSelectedFilePath();
if (!string.IsNullOrEmpty(selectedFilePath))
{
// 使用“选择打开方式”对话框打开文件
ProcessStartInfo psi = new ProcessStartInfo("rundll32.exe", $"shell32.dll,OpenAs_RunDLL {selectedFilePath}");
Process.Start(psi);
}
}
#endregion
#region 顶部控件事件
/// <summary>
/// 选择搜索目录
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnSelectPath_Click(object sender, EventArgs e)
{
if (this.folderBrowserDialog1.ShowDialog() == DialogResult.OK)
this.txtFilePath.Text = this.folderBrowserDialog1.SelectedPath;
}
/// <summary>
/// 搜索
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private async void btnSearch_Click(object sender, EventArgs e)
{
this.lisBoxShow.Items.Clear();
SetSearchStatus("");
string strFilePath = txtFilePath.Text.ToString();
string strSearchText = txtSearchText.Text.ToString();
string strMsg = "";
if (strFilePath == "" || !Directory.Exists(strFilePath)) strMsg = "请选择搜索路径!";
else if (strSearchText == "") strMsg = "请输入搜索内容!";
else if (searchTypes.Count == 0) strMsg = "请选择搜索的文件类型!";
if (strMsg != "")
{
MessageBox.Show(strMsg);
return;
}
kvpSearchTypes = ParseSearchType(searchTypes);
btnSearch.Enabled = false; //搜索开始、禁用按钮
await Task.Factory.StartNew(async () =>
{
await SearchFiles(strFilePath, kvpSearchTypes, strSearchText);
});
btnSearch.Enabled = true;//搜索结束、启用按钮
}
/// <summary>
/// 文件类型改变事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ckbFileType_CheckedChanged(object sender, EventArgs e)
{
SetSearchType();
}
/// <summary>
/// 文件显示列表双击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void lisBoxShow_DoubleClick(object sender, EventArgs e)
{
OpenMenuItem_Click(null, null);
}
#endregion
#region 文件搜索相关
/// <summary>
/// 搜索文件
/// </summary>
/// <param name="fullPath"></param>
/// <param name="kvpSearchTypes"></param>
/// <param name="searchContent"></param>
/// <returns></returns>
private Task<List<string>> SearchFiles(string fullPath, List<KeyValuePair<string, Regex>> kvpSearchTypes, string searchContent)
{
List<string> result = new List<string>();
var stopWatch = new Stopwatch();
stopWatch.Start();
// 取出文件列表,
var files = GetFiles(fullPath, "*", SearchOption.AllDirectories).ToList();
// stopWatch.Stop();
// Console.WriteLine($"EnumerateFiles Count={files.Count()}, Duration={stopWatch.ElapsedMilliseconds} ms");
SetSearchStatus($"准备开始搜索,共{files.Count()}项");
// stopWatch.Start();
// SearchFiles_Type1(files, kvpSearchTypes, searchContent);
result = SearchFiles_Type2(files, kvpSearchTypes, searchContent);
stopWatch.Stop();
Console.WriteLine($"超找文件 Duration={stopWatch.ElapsedMilliseconds} ms");
SetSearchStatus($"搜索完成,共查找文件{files.Count}个,符合条件{result.Count}个");
return Task.FromResult(result);
}
#region 文件搜索具体操作
/// <summary>
/// 文件搜索
/// </summary>
/// <param name="files"></param>
/// <param name="kvpSearchRegex"></param>
/// <param name="searchContent"></param>
/// <returns></returns>
private List<string> SearchFiles_Type2(List<string> files, List<KeyValuePair<string, Regex>> kvpSearchRegex, string searchContent)
{
List<string> result = new List<string>();
//先遍历每一个文件、匹配类型
foreach (var filePath in files)
{
foreach (var type in kvpSearchRegex)
{
if (type.Value.IsMatch(filePath))
{
//文件内容查找,因为文件类型固定,则每个文件只会被读取并查找一次。
if (File.ReadAllText(filePath).Contains(searchContent))
{
result.Add(filePath);
AddSearchFile(filePath);
Thread.Sleep(3);
}
}
}
}
return result;
}
/// <summary>
/// 文件搜索
/// </summary>
/// <param name="files"></param>
/// <param name="kvpSearchRegex"></param>
/// <param name="searchContent"></param>
/// <returns></returns>
private List<string> SearchFiles_Type1(List<string> files, List<KeyValuePair<string, Regex>> kvpSearchRegex, string searchContent)
{
List<string> result = new List<string>();
// 先遍历每一个文件、匹配类型
foreach (var type in kvpSearchRegex)
{
var tFiles = files.Where(f => type.Value.IsMatch(f)).ToList();
foreach (var filePath in tFiles)
{
if (File.ReadAllText(filePath).Contains(searchContent))
{
result.Add(filePath);
AddSearchFile(filePath);
Thread.Sleep(3);
}
}
}
return result;
}
#endregion
private List<KeyValuePair<string, Regex>> ParseSearchType(List<string> fileTypes)
{
List<KeyValuePair<string, Regex>> keyValuePairs = new List<KeyValuePair<string, Regex>>();
foreach (string fileType in fileTypes)
{
string pattern = $@"\{fileType.TrimStart('*')}$";
Regex regex = new Regex(pattern, RegexOptions.IgnoreCase);
keyValuePairs.Add(new KeyValuePair<string, Regex>(fileType, regex));
}
return keyValuePairs;
}
/// <summary>
/// 获取指定目录下满足搜索表达式的文件名列表
/// </summary>
/// <param name="fullPath"></param>
/// <param name="searchPattern"></param>
/// <param name="searchOption"></param>
/// <returns></returns>
public IEnumerable<string> GetFiles(string fullPath, string searchPattern, SearchOption searchOption)
{
return Directory.EnumerateFiles(fullPath, searchPattern, searchOption);
}
/// <summary>
/// 获取选中的文件
/// </summary>
/// <returns></returns>
private string GetSelectedFilePath()
{
// 获取 ListBox 中选中的文件路径
if (lisBoxShow.SelectedItem != null)
{
return lisBoxShow.SelectedItem.ToString();
}
return null;
}
#region 设置搜索类型
/// <summary>
/// 设置类型
/// </summary>
/// <param name="checkBox"></param>
/// <param name="searchTypes">搜索类型</param>
/// <param name="check">是否选中</param>
/// <param name="tips">提示词</param>
private void SetType(CheckBox checkBox, string searchTypes, bool check = false, string tips = null)
{
checkBox.Text = searchTypes;
checkBox.Checked = check;
if (tips != null) toolTip.SetToolTip(checkBox, tips);
}
/// <summary>
/// 设置搜索类型
/// </summary>
private void SetSearchType()
{
searchTypes.Clear();
if (ckbAll.Checked)
{
searchTypes.Add("*.*");
}
else
{
var checkTypes = pnlSearchType.Controls.Cast<CheckBox>().Where(ck => ck.Checked).SelectMany(ck => ck.Text.Split(';')).ToList();
searchTypes.AddRange(checkTypes);
}
}
#endregion
#endregion
#region 异步UI支持
/// <summary>
/// 添加搜索文件
/// </summary>
/// <param name="file"></param>
private void AddSearchFile(string file)
{
AsyncUI(new Action(() =>
{
lisBoxShow.Items.Add(file);
}));
}
/// <summary>
/// 显示搜索状态
/// </summary>
/// <param name="msg"></param>
private void SetSearchStatus(string msg)
{
AsyncUI(new Action(() => lblStatus.Text = msg));
}
private void ShowProgress(int proValue, int? maximum = null)
{
AsyncUI(new Action(() =>
{
if (maximum.HasValue) progressBar1.Maximum = (int)maximum;
progressBar1.Value = proValue;
}));
}
/// <summary>
/// 异步UI支持
/// </summary>
/// <param name="frm"></param>
/// <param name="action"></param>
public void AsyncUI(Action action)
{
if (this.Disposing || this.IsDisposed)
return;
if (this.InvokeRequired)
this.BeginInvoke(action);
else
action?.Invoke();
}
#endregion
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="folderBrowserDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAEAICAAAAEAIACoEAAAFgAAACgAAAAgAAAAQAAAAAEAIAAAAAAAABAAABILAAASCwAAAAAAAAAA
AAD///8A////AP///wDt7e0C3t7eCd/f3wrf398K39/fCt/f3wrf398K39/fCt/f3wrf398K3t7eCt7e
3grf398K3t7eCt7e3gre3t4K3t7eCt7e3gre3t4K3t7eCuzs7AT///8A////AP///wD///8A////AP//
/wD///8A////AP///wD///8A+vr6AIeHhzWpqam1t7e3u7a2tru4uLi7tLS0u7Ozs7uysrK7srKyu7Gx
sbuwsLC7r6+vu6+vr7uurq67ra2tu6ysrLurq6u7q6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//X19f/R0dHN7e3tEv///wD///8A////APf39wBvb25Vo6Ok+dHQ
zf/TyrT/z8Kf/9HEov/Tx6n/1cmt/9XKrv/Vya3/1Mep/9LFpP/QwqD/0car/9TSy/+4uLj/zs7O/+7u
7v/u7u7/7u7u/+7u7v/u7u7/7+/v//Hx8f/z8/P/9PT0/9HR0c3t7e0S////AP///wD///8A9/f3AHd3
d1PLy8v5vb6+/83Ny//Y08f/0MWp/8q8mP/JuZL/ybiQ/8m4kf/JupX/zcGj/9XPvv/U09D/vb29/9TU
1P/09PT/9fX1//X19f/29vb/9vb2//b29v/29vb/9vb2//b29v/4+Pj/1NTUzu3t7RL///8A////AP//
/wD4+PgAZWVlQ4eHh8GMjIzFbW1txY+Pj9vDw8L509DJ/9TQxP/W0ML/1dDD/9TRyP/Lysj9pKSl5m5v
b8aBgYHDl5eXw5aWlsOWlpbDlpaWwpaWlsKWlpbClpaWwpeXl8KXl5fBl5eXwZeXl8SUlJSa7OzsDf//
/wD///8A////APz8/AClpaUIgICAEoKCghKCgoIRjIyMIaqqq1SwsLCRt7i4sa2trr22tre2tbW1n7Gx
sWeVlZUtgoKCEYODgxCCgoIQgoKCEIKCghCCgoIPgoKCD4KCgg+CgoIPgoKCDoKCgg6CgoIOgICADqGh
oQr5+fkA////AP///wD///8A////AP///wD///8A////AP///wD///8A/v7+APn5+QHy8vIF4+PjC+7u
7gf4+PgC/Pz8AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP//
/wD///8A////AP///wD///8A4AAA/+AAAEfgAAAD4AAAAeAAAAHgAAAB4AAAA+AAAAPgAAAB4AAAAeAA
AAHgAAAB4AAAAeAAAAHgAAABwAAAAcAAAAGAAAABgAAAAYAAAAGAAAABgAAAAYAAAAGAAAABgAAAAcAA
AAHAAAAB4AAAAeAAAAHgAAAB4AAAA/+D//8=
</value>
</data>
</root>
\ No newline at end of file
using System;
using System.Windows.Forms;
namespace WindowsSearch
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FrmSearch());
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的常规信息通过下列属性集
// 控制。更改这些属性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("WindowsSearch")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("P R C")]
[assembly: AssemblyProduct("WindowsSearch")]
[assembly: AssemblyCopyright("Copyright © P R C 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 使此程序集中的类型
// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
// 则将该类型上的 ComVisible 属性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("52674a16-1a44-44f2-9862-f78ad6474909")]
// 程序集的版本信息由下面四个值组成:
//
// 主版本
// 次版本
// 内部版本号
// 修订号
//
// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.*")]
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{0A591ECF-134D-40FD-A8E4-57D8A70FC309}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>WindowsSearch</RootNamespace>
<AssemblyName>WindowsSearch</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ApplicationIcon>mainForm.ico</ApplicationIcon>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>3.5</OldToolsVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Runtime.Extensions, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.Extensions.4.3.0\lib\net462\System.Runtime.Extensions.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="FrmSearch.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmSearch.Designer.cs">
<DependentUpon>FrmSearch.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="FrmSearch.resx">
<DependentUpon>FrmSearch.cs</DependentUpon>
</EmbeddedResource>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="min.ico" />
<Content Include="mainForm.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net48" />
</packages>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment