1、 Form public Form1() InitializeComponent(); #region 函数 / / 选中的文件夹/summary private DirectoryInfo _dirSelected; / 检索关键字 private string _strKeyWord; / 存储文件的DataTable private DataTable _dtFileInfo; / 可查找的后缀名 private Hashtable _htExtension; / 检索方式:1 按内容检索 2按文件名称检索 private int _iQueryType = 1; private boo
2、l _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 d
3、lglBindDataTableToDataGridView(); #endregion #region 方法 #region 跨线程访问控件 / 跨线程访问控件:显示检索文件名param name=strMsg private void AccessToControl_ShowSearchFileName(string strMsg) if (this.InvokeRequired) dlgShowSearchFileName dlgShowMsg = new dlgShowSearchFileName(AccessToControl_ShowSearchFileName); this.lb
4、lSearchMsg.Invoke(dlgShowMsg, new object strMsg ); else this.lblSearchMsg.Text = string.Format(正在检索 0, strMsg); private void AccessToControl_BindDataTableToDataGridView() this.Invoke(new dlglBindDataTableToDataGridView(delegate() this.dataGridView1.DataSource = null; this.dataGridView1.DataSource =
5、this._dtFileInfo; ); #region 搜索 / 检索 private void Search() ArrayList alFile = new ArrayList(); SearchFiles(this._dirSelected, ref alFile); / 遍历文件夹下的所有文件infoalFileInfo private void SearchFiles(FileSystemInfo info, ref ArrayList alFileInfo) if (!this._bFlagRunCompleted) if (!info.Exists) return; DirectoryInfo dir = info as DirectoryInfo; if (dir = null) return; FileSystemInfo files = dir.GetFileSystemInfos(); for (int i = 0; i 0) /添加到表格 AddToDataGridView(file, iRowNumber); a
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1