We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

hard drive search

tdiamond
tdiamond asked
on
Medium Priority
167 Views
Last Modified: 2010-05-03
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.
Comment
Watch Question

I think I have the solution. Give me a few moments and I will be back with the solution.
Dr. Kamal MehdiIT Director / IT Project Manager
CERTIFIED EXPERT

Commented:
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

Dr. Kamal MehdiIT Director / IT Project Manager
CERTIFIED EXPERT

Commented:
tdiamond, give me your e-mail address to get the complete project.
Dr. Kamal MehdiIT Director / IT Project Manager
CERTIFIED EXPERT

Commented:
tdiamond, please reject the proposed answer so I can lock the question and send you the project.
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.
Dr. Kamal MehdiIT Director / IT Project Manager
CERTIFIED EXPERT

Commented:
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

Author

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.
IT Director / IT Project Manager
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
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.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.