/// <summary> /// 内容查找 /// </summary> /// <param name="searchValue"></param> private void ContentCheck(string searchValue, IList <FileInfo> fileList, CountdownEvent handler, Action <string> listbox2Delegate, Action <string> disedDelegate) { CommForAdolph.OfficeHelper officeHelper = new CommForAdolph.OfficeHelper(); foreach (var item in fileList)//listBox1.Items) { if (handler.CurrentCount == 0) { return; } //文件全路径 var itemStr = item.FullName.ToString(); int fileNameStartIndex = itemStr.LastIndexOf('\\'); if (itemStr.Substring(fileNameStartIndex, itemStr.Length - fileNameStartIndex).Contains(searchValue)) { if (!listBox2.Items.Contains(itemStr)) { this.listBox2.BeginInvoke(listbox2Delegate, itemStr); } //listBox2.Items.Add(item); } if (itemStr.Contains("~$")) { continue; } if (item.Extension == ".doc" || item.Extension == ".docx") { if (officeHelper.CheckWordContent(itemStr, searchValue)) { this.listBox2.BeginInvoke(listbox2Delegate, itemStr); } } else if (item.Extension == ".xls" || item.Extension == ".xlsx") { if (officeHelper.CheckExcelContent(itemStr, searchValue)) { this.listBox2.BeginInvoke(listbox2Delegate, itemStr); } } //检查搜索内容 else if (IOHelperExt.CheckContent(searchValue, itemStr) != -1) { this.listBox2.BeginInvoke(listbox2Delegate, itemStr); } if (handler.CurrentCount > 0) { handler.Signal(); this.label1.BeginInvoke(disedDelegate, handler.CurrentCount.ToString()); } } }
private void button1_Click(object sender, EventArgs e) { CommForAdolph.OfficeHelper officeHelper = new CommForAdolph.OfficeHelper(); officeHelper.CheckWordContent(@"E:\工作内容归档\任务文档\JL-CX-121-P+MEL编写修订申请表.doc", "MEL"); }