# VBForums UtilityBank > UtilityBank - Utilities >  Utility - File Search

## ProphetBeal

*NOTE: VERSION 2.0 IS LOCATED HERE*

*Title:* FileFind
*Description:* 
I built this utility as a replacement to the default windows search.  It contains the same basic functionality as the windows search.  It allows you to search by a whole/part of a file name and/or by as string within a file.  It displays the search results in a List View and allows you to export the results to Excel (FYIit uses late binding so Excel is not required to run the Utility).
*Features:*
Search by all or part of a file nameSearch by a string within a fileCan export results to Excel (FYIit uses late binding so Excel is not
required to run the Utility)Can open any file foundCan open the directory of any file foundAllows you to pause/resume the searchAllows you to cancel the searchOptional  Get a count of how many times a string appears within the found fileOptional  Search case sensitiveOptional  Include Sub folders in search
*Screen Shots:*
 

*Author:* Sean Lodespoto A.K.A ProphetBeal
*System Requirements:*This code was written in VB.Net 2003 (V 1.1), so to view the code you need that version or aboveTo use the executable you need at minimum the .Net Framework Version 1.1
*License Info:*
You can use my Utility or parts of the code where ever you want, but GIVE CREDIT WHERE ITS DUE.

----------


## vbfbryce

Looks awesome.  Tried to run a simple search and got the following error:


"cmdBeginSearch_Click Error:  Cross-thread operation not valid:  Control 'stbSearchInfo' accessed from a thread other than the thread it was created on."


I ran it in 2008 Express.  Should that make any difference?

Thanks!

Bryce

----------


## ProphetBeal

I'm not quite sure why you are getting that error.  There could be an issue that the 3.5 framework imposes more security than the 1.1.  I'll have to take a look at this, when I get a chance.  The example I provided above is pretty old and actually I forgot it was even here, so I'll update it soon.

----------


## vbfbryce

Appreciate it, man.  Thanks!

Like your website, btw!

----------


## ProphetBeal

I have made some changes to this code and in fact the application overall.

The main layout is still the same however most of the code has been replaced.

*Main Updates:*
Has been built against the 3.5 framework in VS 2008The Excel Export feature no longer uses late binding.Allowed multi threading of search and form

----------


## vbfbryce

Excellent, thanks!

I'll check it out!

----------


## vbfbryce

Beal,

I had to add a COM reference to "Microsoft Excel 10.0 Object Library."  After doing so, it worked great!

It is much faster than the search apps I've been toying with, so thanks!

Mind if I steal shamelessly from your code?!

Bryce

----------


## ProphetBeal

If I minded...I wouldn't have posted it  :Big Grin:

----------


## Spoo

Beal

Man, 1394 views of original code and you only have 65+ rep points?
That blows !
Here is at least 1 more  :Thumb: 
Nice work.

Spoo

----------


## ja2984

Hey ProphetBeal thanks for the Software, works great  :Thumb: 

I've managed to blend it in with a program i wrote and have stumbled across a few questions you might be able to help me with.

1) can i change the search criteria so that it only searches through files that have extension *.lst. I've done this for my program but i have no idea where to start editing your code, i'm self taught  :Blush: 

2) Can i modify the "Right click" menu of each item found. i.e. i want to disable export to excel and maybe add a custom feature.

3) Can i modify the "double click" routine so that it copies the file name to another textbox on my program. ie: if i find file....C:\MyFolder\TF12345.lst i want to store "12345" in a text box on my form for later use.

4) For some reason the status bar at the bottom wont display the current status. All i did was copy it directly from your form to mine and made sure i have all relevent code in the background. It looks as though the "tooltips" and "statustext" are being changed properly but not displaying. Any ideas how or why this could happen?

5) How would you like me to Credit all your great efforts in providing this code for us not so clever to use :Alien Frog:  Have u got a sig or pic or anything? So far i've added your name to the "aboutbox" in my program.

Well i know thats a lot of questions so i dont expect u to answer them all at once or even answer all of them, so having said any help is much, much appreciated.

Thanks

John :wave:

----------


## ProphetBeal

> 1) can i change the search criteria so that it only searches through files that have extension *.lst. I've done this for my program but i have no idea where to start editing your code, i'm self taught


In my app there is a text box for just that purpose.  The control name is "txtFileName" and it's labeled on the form as "All or part of the file name:"



> 2) Can i modify the "Right click" menu of each item found. i.e. i want to disable export to excel and maybe add a custom feature.


You need to edit the "cmnOpenResults" context menu control



> 3) Can i modify the "double click" routine so that it copies the file name to another textbox on my program. ie: if i find file....C:\MyFolder\TF12345.lst i want to store "12345" in a text box on my form for later use.


Sure, that would be done in the "lsvFilesFound_DoubleClick" Sub



> 4) For some reason the status bar at the bottom wont display the current status. All i did was copy it directly from your form to mine and made sure i have all relevent code in the background. It looks as though the "tooltips" and "statustext" are being changed properly but not displaying. Any ideas how or why this could happen?


I can't really say why this isn't working.  If your app isn't multi-threaded correctly that could have something to do with it (IE the screen isn't getting refreshed because the thread is busy).  

If you want more with this issue I suggest creating a thread in the VB.NET forums and post some of your code there.



> 5) How would you like me to Credit all your great efforts in providing this code for us not so clever to use Have u got a sig or pic or anything? So far i've added your name to the "aboutbox" in my program.


A note at the top of your code with my name and a link to this thread would be more than enough.

I hope these answers helped.  :Thumb:

----------


## ja2984

Thanks ProphetBeal, i'll have a look into the answers and see if i cant nut out what i need. 

I'll do dome more research on why my status bar is not working, basically what u said about the thread being busy went over my head (giraffes fart) hehe.

I'll add your details and link to my code and about form.

Thanks once again,

John.

----------


## AsyLuM

Hello ProphetBeal, your software is great !
I've seen some problems when using this latter : 

- In the first textbox ("A word or phrase within the file") : the software finds some fakes results (the word that I choose isn't in the PDF Files).

- In the second textbox ("All or part of the file name") : so as to find a file, I have to put an * just before and after my search.

How to resolve these problems ?

Thank you so much.

Julien.

----------


## ProphetBeal

> - In the first textbox ("A word or phrase within the file") : the software finds some fakes results (the word that I choose isn't in the PDF Files).


It scans the binary versions of the files, so I will bet if you use Notepad to open the PDF in question and search for that text it will find it.  I'm not really sure how to avoid this.  Any suggestions are welcome.




> - In the second textbox ("All or part of the file name") : so as to find a file, I have to put an * just before and after my search.


Not sure what the issue here is.  Are you saying you don't like using "*"?  The built in windows searches use a similar methodology "*.pdf" will only search PDF files.

----------


## AsyLuM

Using "*" is not a problem.

Indeed, when I try to open PDF files with notepad, it shows me some misunderstanding thing like this,"OaóÕ¶jëõy±¬Èénr*". And , by chance, there is the letters association I'm looking for but not really the word. 

I'm sorry but I can't help you to improve your software.

----------


## AsyLuM

Hi ProphetBeal,

according to the PDF file problems, I've find the code of stanav ! ( add reference : itextsharp.dll (the 4.0.1 works better than the last with my VS2008) and SharpZipLib.dll)

This latter finds the text in the PDF and puts it in a string value.

Can you tell me how to adapt it to your code ?

Thank you.

PS : Sorry for my bad english.

Julien.

----------


## em07189

HI!

How can i modify the code to search files by it's extension when the folder options are set  to hide the file extension??

thanks.

----------

