|
-
Feb 12th, 2003, 11:08 AM
#1
Thread Starter
Addicted Member
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.
-
Feb 12th, 2003, 12:43 PM
#2
yay gay
open each file and do a search for the word "test" using .IndexOf() function
\m/  \m/
-
Feb 12th, 2003, 12:56 PM
#3
Thread Starter
Addicted Member
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.
-
Feb 15th, 2003, 11:57 AM
#4
Thread Starter
Addicted Member
For the benifit of others this topic has been resolved at this site:
http://www.developerfusion.com/forum....aspx?id=12307
-
Mar 2nd, 2003, 07:58 PM
#5
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|