RE: Understanding Dir() function
From: Joe (Joe_at_discussions.microsoft.com)
Date: 08/27/04
- Next message: David Hodgkins: "Source control"
- Previous message: Joe: "Understanding Dir() function"
- In reply to: Joe: "Understanding Dir() function"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 27 Aug 2004 06:21:02 -0700
Never mind. I got it.
"Joe" wrote:
> I have been using the following code (supplied by Tim Baur) to recurse
> through the directories of a drive in search of all instances of a file (i.e.
> aFile.txt).
>
> What I don't understand is once I've retrieved the root directory of the
> drive and am processing through the Do...Loop, why does sItem = Dir() return
> the files in the root directory since I began the Do...Loop wth
> Dir(sStartDir, vbDirectory)? I thought that the Dir() function should only
> return files (or directories in this case) that match the search criteria in
> the Dir() function.
>
> Can anyone help with this?
>
> Here's the code:
>
> [snip]
>
> 'retrieve the first directory
> sItem = Dir(sStartDir, vbDirectory)
> Do
> If sItem <> "." And sItem <> ".." And sItem <> vbNullString Then
> sItems = sItems & "|" & sItem
> End If
> sItem = Dir()
> Loop Until sItem = vbNullString
>
> sItemArr = Split(sItems, "|")
>
> For i = 1 To UBound(sItemArr)
> sItem = sItemArr(i)
> iAttr = GetAttr(sStartDir & sItem)
> If iAttr >= vbDirectory And iAttr < vbArchive Then
> SearchFile = SearchFile(sFile, sStartDir & sItem)
> If SearchFile <> vbNullString Then Exit For
> Else
> If sItem = sFile Then
> SearchFile = sStartDir & sItem
> Exit Function
> End If
> End If
> Next i
> --
>
> TIA,
> Joe
>
> VBA Automation/VB/C++/Web and DB development
- Next message: David Hodgkins: "Source control"
- Previous message: Joe: "Understanding Dir() function"
- In reply to: Joe: "Understanding Dir() function"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|