Listing Termination

If an application does not interrupt the ReadDirectory loop, and all entries are successfully processed, then ReadDirectory will eventually return an error indicating that the end of the directory listing has been reached.

If the ParseList property was set to a value of true, the ReadDirectory method will return a value of fileErrorEndOfDirectory when the last file has been returned. If the ParseList property is set to false, the method will return a value of fileErrorEndOfData.

Regardless of how the end of the listing data is indicated, the directory listing must be explicitly terminated by calling the CloseDirectory method.

nError = FileTransfer1.OpenDirectory(strDirName)
If nError <> 0 Then
    MsgBox FileTransfer1.LastErrorStrong, vbExclamation
    Exit Sub
End If

Do
    nError = FileTransfer1.ReadDirectory(strFileName, _
        dwFileLength, strFileDate, _
        strFileOwner, strFileGroup, _
        dwFilePerms, bIsDirectory)
    If nError <> 0 Then
        If nError <> fileErrorEndOfDirectory And _
           nError <> fileErrorEndOfData Then
           MsgBox FileTransfer1.LastErrorStrong, vbExclamation
        End If
        Exit Do
    End If
Loop
FileTransfer1.CloseDirectory

Copyright © 2008 Catalyst Development Corporation. All rights reserved.