2024年4月21日发(作者:)
using System;
using tions;
using c;
using entModel;
using ;
using g;
using ;
using ;
using ;
namespace Search
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
#region 函数
///
/// 选中的文件夹
///
private DirectoryInfo _dirSelected;
///
/// 检索关键字
///
private string _strKeyWord;
///
/// 存储文件的DataTable
///
private DataTable _dtFileInfo;
///
/// 可查找的后缀名
///
private Hashtable _htExtension;
///
/// 检索方式:1 按内容检索 2按文件名称检索
///
private int _iQueryType = 1;
private bool _bFlagRunCompleted = true;
///
/// 是否区分大小写
///
private bool _bFlagIsUpLower = true;
private const int _GB = 1024 * 1024 * 1024;//定义GB的计算常量
private const int _MB = 1024 * 1024;//定义MB的计算常量
private const int _KB = 1024;//定义KB的计算常量
private delegate void dlgShowSearchFileName(string strMsg);
private delegate void dlglBindDataTableToDataGridView();
#endregion
#region 方法
#region 跨线程访问控件
///
/// 跨线程访问控件:显示检索文件名
///
///
private void AccessToControl_ShowSearchFileName(string strMsg)
{
if (Required)
{
dlgShowSearchFileName dlgShowMsg = new
dlgShowSearchFileName(AccessToControl_ShowSearchFileName);
(dlgShowMsg, new object[] { strMsg });
}
else
{
= ("正在检索 {0}", strMsg);
}
}
private void AccessToControl_BindDataTableToDataGridView()
{
(new dlglBindDataTableToDataGridView(delegate()
{
urce = null;
urce = this._dtFileInfo;
}));
}
#endregion
#region 搜索
///
/// 检索
///
private void Search()
{
ArrayList alFile = new ArrayList();
SearchFiles(this._dirSelected, ref alFile);
}
///
/// 遍历文件夹下的所有文件
///
///
///
private void SearchFiles(FileSystemInfo info, ref ArrayList alFileInfo)
{
if (!this._bFlagRunCompleted)
{
if (!) return;
DirectoryInfo dir = info as DirectoryInfo;


发布评论