Link to home
Start Free TrialLog in
Avatar of VBDesigns
VBDesigns

asked on

How do I search for a file?

What's the best method to search for a file on the hard drive on Win9x, NT, and Win2000 systems?

I need to find out if my application was already installed, and if so, where...  Of course I could write out a registry entry, but without this, what's the next best method?
Avatar of vbWayne
vbWayne

'does file exist using fso

Dim sFile$

sFile = "Name And Path Of Your File"

Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")

If fs.fileexists(sFile$) = True Then
      MsgBox "File Exists...Your code here!"
Else
      MsgBox "Does Not Exist...Your code here!"
End If
      Set fs = Nothing


Ooops...the above only works if you know tht path. Sorry.
Avatar of VBDesigns

ASKER

If I knew the path I wouldn't have to search!  Sorry, I don't see how this answer applies unless the external call searches all hard drives and returns a directory.
ASKER CERTIFIED SOLUTION
Avatar of Dr. Kamal Mehdi
Dr. Kamal Mehdi
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I only have VB6.  I'll have to install the samples I guess.  I was just hoping there was a way to hook into the OS file search mechanism...
If you like, I can e-mail it to you.
Comment me your e-mail address.
Actually, I went ahead and used the registry for what I needed to do.  I'll give you the points for answering though - thanks!
Thanks and you are welcome.
Happy new year.