By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,391 Members | 1,653 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,391 IT Pros & Developers. It's quick & easy.

Search for a file on all drives of a computer

P: n/a
Hi there,

I would need your help again.

I am using Dev Avish's API function "Search for a file"
http://www.mvps.org/access/api/api0006.htm
to find a file on my computer which works well. As you may know, in this
function the user needs to specify the drive which is then searched for
the specific file.

What I would like to do, however, is to search all drives incl.
removable devices of the computer for a file. I have tried to use "My
Computer" as strDrive, but this does not really work.

Can anyone point me into the right direction ... ?

Many thanks!

Best regards,

Sabine

*** Sent via Developersdex http://www.developersdex.com ***
Sep 6 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Sep 6, 10:59 am, Sabine <sabine.xxxoebbe...@xxxunilever.comwrote:
Hi there,

I would need your help again.

I am using Dev Avish's API function "Search for a file"http://www.mvps.org/access/api/api0006.htm
to find a file on my computer which works well. As you may know, in this
function the user needs to specify the drive which is then searched for
the specific file.

What I would like to do, however, is to search all drives incl.
removable devices of the computer for a file. I have tried to use "My
Computer" as strDrive, but this does not really work.

Can anyone point me into the right direction ... ?

Many thanks!

Best regards,

Sabine

*** Sent via Developersdexhttp://www.developersdex.com***
Since 'all drives' can be a dynamic thing (floppy, removable,
external, network, etc) you can open a huge can of worms searching
'all drives'. You could test for eash drive letter A: - Z: and if it
exists search for the file(s) in question. Even without any overhead
issues, searching 'all drives' could be an extremely time consuming
process...
Sep 6 '07 #2

P: n/a
Sabine wrote:
Hi there,

I would need your help again.

I am using Dev Avish's API function "Search for a file"
http://www.mvps.org/access/api/api0006.htm
to find a file on my computer which works well. As you may know, in this
function the user needs to specify the drive which is then searched for
the specific file.

What I would like to do, however, is to search all drives incl.
removable devices of the computer for a file. I have tried to use "My
Computer" as strDrive, but this does not really work.

Can anyone point me into the right direction ... ?

Many thanks!

Best regards,

Sabine

*** Sent via Developersdex http://www.developersdex.com ***
This will loop thru drives A-Z.

Sub ScanAndSearchAllDirs()
Dim intDir As Integer
Dim strDir As String
Dim lngErr As Long
For intDir = 65 To 90
On Error GoTo 0
On Error Resume Next
strDir = DIr(Chr(intDir) & ":\*.*")
If Err.number = 0 Then
'search routine here
'MsgBox Chr(intDir) & " " & strDir
End If
Next intDir
MsgBox "Done"

End Sub
Sep 6 '07 #3

P: n/a
This is p e r f e c t .

It works :).

Many thanks!

Sabine

*** Sent via Developersdex http://www.developersdex.com ***
Sep 7 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.