Source code for Issue Number 81

Copyright 1997-2000 by C&D Programming Corp. All Rights Reserved. Source code may not be reproduced except for use in a compiled executable. All rights reserved. If you would like to reprint any or all of this code please email us at info@codeoftheweek.com

Code of the Week Home


Source Code

In order to save some bandwidth we are only showing the additions to issue #80. Just paste this code right before the FindFile routine in Issue #80. If you have any questions, email us at issue81help@codeoftheweek.com

'----------------------------------------------------------------------
'
'   Module Name:    cFindFiles
'   Written By:     Tracy Martin
'   Modifications:  C&D Programming Corp.
'   Create Date:    2/99
'   Copyright:      Copyright 1999 by C&D Programming Corp.  Source
'                   code may not be reproduced except for use in a
'                   compiled executable.  All rights reserved.  If
'                   you would like to reprint any or all of this
'                   code please email us at info@codeoftheweek.com
'----------------------------------------------------------------------

'
'
'   PLEASE NOTE THAT YOU NEED THE SOURCE CODE FROM
'   ISSUE #80 TO COMPLETE THIS CLASS!
'
'
'
'
'

Public Event FoundFile(fnd As cFindFiles)

Public Sub FindAllFiles(sDir As String, sFileMask As String)
    Dim fnd As New cFindFiles
    Dim bContinue As Boolean

    ' handle any kind of trailing character
    If Right(sDir, 1) = "\" Then
        bContinue = fnd.FindFile(sDir & sFileMask)
    Else
        bContinue = fnd.FindFile(sDir & "\" & sFileMask)
    End If
    While bContinue
        If Not fnd.IsDots() Then
            RaiseEvent FoundFile(fnd)
            If fnd.IsDirectory Then
                FindAllFiles fnd.GetFilePath, sFileMask
            End If
        End If
        bContinue = fnd.FindNextFile
    Wend
End Sub


Public Property Get IsDots() As Boolean
' IsDots: Determine if the currently "found" file is the "." or ".." directory
'
' Incoming parameters:
'     
'
' Returned parameters:
'    Boolean: True if directory is "." or "..", false otherwise
'
    If IsDirectory Then
        If Trim(FileData.cFileName) = "." Or Trim(FileData.cFileName) = ".." Then
            IsDots = True
            Exit Property
        End If
    End If
    IsDots = False

End Property

Public Property Get IsDirectory() As Boolean
' IsDirectory: Determine if the currently "found" file is actually a directory
'
' Incoming parameters:
'     
'
' Returned parameters:
'    Boolean: True if "file" is a directory, false otherwise
'
    IsDirectory = (FileData.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY)
End Property