类似Windows Search的文件搜索系统
?
?
IntroductionWinSearchFile is a program that I developed and I usually use it to search files on my PC.
Sometimes the search engine integrated with Explorer doesn't work fine, especially when I try to find text contained into files, so I decided to build my own search program.
There are a lot of search programs available to install on your PC but this one, without indexing your data, is simple and fast enough to help you in your search.
Inside the applicationWinSearchFile layout is simple and quite similar to the Explorer integrated search. It is possible to write a pattern search (wildcards admitted) and/or a text to search into file contents (you can also decide for a case sensitive search).
In the "look in" area, you have all the disks of your computer (network connection included). To obtain this list, I use the DiskCollection class developed by dmihailescu in his Get Logical Drives Information article.
?
In the WinSearchFile application, I use threads to make the same search simultaneously on different targets; I use a thread for each target drive.
CollapseCopy Code
?
Threads use the
CollapseFileSearchclass to do their work. To update controls or data structures on main threads, use delegate functions. I defined a delegate function for theAddListBoxItemmethod:Copy Code
CollapseCopy Code
Abort method. CollapseCopy Code
To quick launch WinSearchFile, you can create a shortcut to it on your desktop and assign to this one a shortcut key.
?
ConclusionI hope you enjoy this article.
New WinSearchFile versionThe new WinSearchFile 2.0, built using Visual Studio 2005 and C# 2.0, contains the following new features:
Single Instance Application using code written by Eric Bergman-Terrell.Search inside PDF files.Regular expression searching.Searching using IFilter.Max directory visit depth.FileCreation TimeorLast ACcess TimeorLast Write Timesearchingdirectory list to search into.Save resultsbutton.Here is a new screenshot:
?
About IFilterUser can decide to use installed IFilter to extract plaintext from files. To implement this interface I used 2 class developed by Dan Letecky.
The following code shows where I try to use IFilter to get plaintext:
CollapseCopy Code
?
LicenseThis article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)
About the AuthorMassimo Beatini
Italy?
转自:http://www.codeproject.com/KB/files/winsearchfile.aspx
下载:http://download.csdn.net/source/1790306