VB.NET File Search

Posted on 2009-04-19
Last Modified: 2012-05-06
I am trying to create a function in my application that will search for key words either in the file name or within the file like windows xp does. I have found a few links that will search the file name but am looking for guidance for searching within the document. Should i just open the file and read contents and look for my key words like that or is there an easy way?
Question by:jimseiwert
    LVL 74

    Expert Comment

    by:käµfm³d 👽
    Yes, you would need to open each (text) file in order to search for keywords--that is unless you are planning to make your own indexing application to speed up searches (the way XP does).
    LVL 9

    Expert Comment

    This class built by someone could help you out.. You would just have to add to open each file found to search within it.
    LVL 3

    Accepted Solution

    How about using:

    My.Computer.FileSystem.FindInFiles("c:\directory", "text", True, SearchOption.SearchAllSubDirectories, "*wildcard")


    item 1 = the directory to search
    item 2 = the text to find in the file or filename
    item 3 = obvious
    item4 = wildcards
    LVL 3

    Expert Comment

    My fault:

    item 3 = boolean (ignore case)
    item 4 = search type
    item 5 = wildcards
    LVL 74

    Expert Comment

    by:käµfm³d 👽
    I stand corrected. I wonder how it performs...

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Introduction When many people think of the WebBrowser ( control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now