• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 156
  • Last Modified:

hard drive search

I am trying to write a program that will search every directory on person's hard drive (C:) for a number of files.  I was wondering if someone could either tell me where on the Internet to find the code or, if someone has the code handy and would be willing to give it to me, I would greatly appreciate it.
0
tdiamond
Asked:
tdiamond
1 Solution
 
redbaron082997Commented:
I think I have the solution. Give me a few moments and I will be back with the solution.
0
 
kamallCommented:
redbaron: Please DO NOT lock the question without providing an answer!!!

tdiamond, here is the code:

   Option Explicit

        Dim colFiles As Collection

        Private Sub Command1_Click()
            Dim vIte As Variant
             
            Set colFiles = New Collection
            MyFindFiles "C:\", Text1.Text
            For Each vIte In colFiles
                MsgBox vIte
            Next vIte
            Set colFiles = Nothing
             
        End Sub

        Private Sub MyFindFiles(ByVal sPath As String, ByVal sFilePattern As String)
            Dim sFile As String
            Dim vIte As Variant
            Dim colDir As New Collection
             
            On Error Resume Next
             
            sFile = Dir$(sPath & sFilePattern)
            While sFile <> ""
                If Left$(sFile, 1) <> "." Then
                    colFiles.Add sPath & sFile
                End If
                sFile = Dir$
            Wend
                 
            sFile = Dir$(sPath, vbDirectory)
            While sFile <> ""
                If Left$(sFile, 1) <> "." Then
                    If GetAttr(sPath & sFile) And vbDirectory Then
                        colDir.Add sPath & sFile & "\"
                    End If
                End If
                sFile = Dir$
            Wend
             
            For Each vIte In colDir
                MyFindFiles vIte, sFilePattern
            Next vIte
             
            Set colDir = Nothing
        End Sub

0
 
kamallCommented:
tdiamond, give me your e-mail address to get the complete project.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
kamallCommented:
tdiamond, please reject the proposed answer so I can lock the question and send you the project.
0
 
redbaron082997Commented:
KAMALL: YOU MUST HAVE WOKEN UP ON THE WRONG SIDE OF THE BED. IT IS COMMON PRACTICE TO LOCK A QUESTION IN ORDER TO PREPARE AN ANSWER THAT I HAD. UNFORTUNEATLY YOU DID NOT SHOW THE RESPECT THAT WAS DUE. YOUR ANSWER IS CORRECT, THEREFORE TDIAMOND DOES NEED TO AWARD TO THE POINTS TO YOU. I FEEL THAT YOU ARE TOTALLY OUT OF PLACE, AS I LOCKED THE QUESTION JUST A FEW MOMENTS AGO IN ORDER TO ANSWER THE QUESTION.

TDiamond:
Go ahead and reject the answer, as the answer I had was the same as provided by kamall.
0
 
kamallCommented:
redborn:
-"IT IS COMMON PRACTICE TO LOCK A QUESTION IN ORDER TO PREPARE AN ANSWER THAT I HAD"!
This is COMPLETELY WRONG! - Who told you that???
Can you imagine how would it going to be if every expert locks every question to PREPARE an answer?. If it is going to be that way, I would have been the #1 expert since long time ago.

-"UNFORTUNEATLY YOU DID NOT SHOW THE RESPECT THAT WAS DUE"
Respect for what??? For proposing an answer without the answer?

tdiamond, sorry for using your thread, but I had to comment on redbaron's comment.
Regards
0
 
tdiamondAuthor Commented:
Hey guys,

Can't we just all get along?

Thank you both.  I greatly appreciate all your help.

P.S. - Kamall, if you have anything else to send me, my e-mail address is td@wwa.com.
0
 
kamallCommented:
tdiamond,
I've just sent you the complete project.
Regards
0
 
vbmeisterCommented:
Besides all of that Emailing an answer does nobody else on the exchange any good at all.  

I completely agree that the person who posts actual code to the EXchange as Kamall did should be the person to lock the question not somebody who says I have an answer let me email it.  Yes we can all get along but Redbaron may have needed to have this pointed out that locking and emailing just kills the thread and we all need the threads to get our answers from rather than having to ask questions everytime to get our own emailings.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now