It's easy. You need to do it by yourself.
You need to use:
System.IO.Directory.GetFiles
,
http://msdn.microsoft.com/en-us/library/system.io.directory.getfiles.aspx[
^].
There is one unpleasant problem with this API. To take it into account, please see this discussion:
Directory.Get.Files search pattern problem[
^].
The rest of search is on yours: you need to open each file, read it and perform the search in it contents. It depends of file formats and your criteria.
If you want to do it with UI and show results as they appear, it will take some considerable work. First of all, you will need to do all the search is a separate thread. Then, you will need to have a control as a sink of search result (I would suggest some
ListBox
). But how to put found data on UI as they appear? This is a bit harder to do.
You cannot call anything related to UI from non-UI thread. Instead, you need to use the method
Invoke
or
BeginInvoke
of
System.Windows.Threading.Dispatcher
(for both Forms or WPF) or
System.Windows.Forms.Control
(Forms only).
You will find detailed explanation of how it works and code samples in my past answers:
Control.Invoke() vs. Control.BeginInvoke()[
^],
Problem with Treeview Scanner And MD5[
^].
See also more references on threading:
How to get a keydown event to operate on a different thread in vb.net[
^],
Control events not firing after enable disable + multithreading[
^].
—SA