search a file

Tomba

Member
Joined
Jul 22, 2003
Messages
17
hi,

is there any way I can do a search for a file from withing a C# program? (I know the exact filename)
At that time, I should be able to show an endless progress-bar, just like with the search function in windows explorer.

thanks in advance!
 
You can use the GetDirectories and GetFiles methods of the System.IO.Directory class to enumerate the folders and files in any directory. If you use this recursively this can enable you to search an entire drive. Ideally you should do this in a new thread (or call Application.DoEvents() periodically in the loop) since this will be an expensive operation in terms of both cpu and disk usage.

The Windows Forms progressbar doesnt wrap the "infinite progress bar" appearance available under Windows XP, so youll have to either implement that manually (consult MSDN for the window style) or do something different.
 
Back
Top