?
Solved

How to search

Posted on 2004-11-19
3
Medium Priority
?
171 Views
Last Modified: 2010-04-23
I am using VB 2003, and am wondering how you make it perform a search. Like say I want to make a program to search for explorer.exe how would I do this?
0
Comment
Question by:tenchi86
  • 2
3 Comments
 
LVL 19

Accepted Solution

by:
arif_eqbal earned 500 total points
ID: 12632406
You mean search for a particular File in the System ???

You need to recursively search all the Drives/Folders/Sub-Folders
Or if you want access to some system files like explorer.exe which you know are in a particular path you can directly access

here's a code for recursive searching

   Public Sub ProcessDirectory(ByVal targetDirectory As String)
        Dim fileEntries As String() = Directory.GetFiles(targetDirectory)
        Dim fileName As String
        For Each fileName In fileEntries
            If fileName.ToUpper = "EXPLORER.EXE" Then
                MsgBox("Found")
                Exit Sub
            End If
            Application.DoEvents()
        Next fileName
        Dim subdirectoryEntries As String() = Directory.GetDirectories(targetDirectory)
        Dim subdirectory As String
        For Each subdirectory In subdirectoryEntries
            ProcessDirectory(subdirectory)
            Application.DoEvents()
        Next subdirectory
    End Sub

call it like ProcessDirectory("C:\")
0
 

Author Comment

by:tenchi86
ID: 12634177
Thanks I will try this later it seems to be what I needed though. Also yes pretty much I just wanted to make vb go into say my computer/C:/programs and find what file I tell it to find.
0
 

Author Comment

by:tenchi86
ID: 12634704
Sorry, for asking this but im a complete noob to this. When I try and run this it pretty much says cannot run debug file not found. So I am screwing up some wheres just not sure where. Also say I wanted it to find say just the winamp file and not winamp.exe do I just replace winamp.exe with winamp?
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses
Course of the Month15 days, 13 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question