Results 1 to 5 of 5

Thread: Search for file containing a word? [Resolved]

  1. #1

    Thread Starter
    Addicted Member ProgrammerJon's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    203

    Question Search for file containing a word? [Resolved]

    I have this code:

    Code:
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            ' make a reference to a directory
            Dim di As New IO.DirectoryInfo("c:\")
            Dim diar1 As IO.FileInfo() = di.GetFiles("test.txt")
            Dim dra As IO.FileInfo
    
            'list the names of all files in the specified directory
            For Each dra In diar1
                ListBox1.Items.Add(dra)
            Next
        End Sub
    If I want to filter the search then I change di.GetFiles("righ here")
    What do I do if I want to search for something similar to something.

    ex.
    If I wanted to search for files containg the word "Test" then what would I do?
    Last edited by ProgrammerJon; Feb 15th, 2003 at 11:58 AM.

  2. #2
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    open each file and do a search for the word "test" using .IndexOf() function
    \m/\m/

  3. #3

    Thread Starter
    Addicted Member ProgrammerJon's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    203
    I don't know how to use the .IndexOF() function.

    I'm not sure if you understood the question;
    If there were these files in the root of drive c:/
    test1.txt
    test is my name.txt
    test234.txt
    my test1.txt
    this is test34.txt

    Then if I searched for the word "test" then I would want all these to come up. I don't want to search inside a file, I want to search in a directory.

  4. #4

    Thread Starter
    Addicted Member ProgrammerJon's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    203
    For the benifit of others this topic has been resolved at this site:
    http://www.developerfusion.com/forum....aspx?id=12307

  5. #5
    Member JesusFreak's Avatar
    Join Date
    Feb 2003
    Location
    Headed for Heaven
    Posts
    57
    The Easiest way to search for anything is to use the office.FileSearch namespace.

    Dim Search As System.Office.FileSearch
    That if you confess with your mouth, "Jesus is Lord," and believe in your heart that God raised him from the dead, you will be saved.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width