OpenDirectory Method

Open the specified directory on an FTP server.

Syntax

object.OpenDirectory([DirName] [, ParseList])

The object placeholder represents an expression that evaluates to a FileTransfer object.

Return Type

Integer

Remarks

The OpenDirectory method opens the specified directory on the server so that the list of files in that directory may be read.

The optional DirName argument specifies the directory on the remote server. If it is an empty string, it designates the current remote directory. It may also be a file mask that includes wildcards if supported by the server. If this argument is omitted, then the current working directory will be opened.

The optional ParseList argument, whose allowable values are True and False, controls whether the directory listing will be parsed as it is read. The default value is True. If ParseList is False, then each entire un-parsed line of a directory listing will be returned in the FileName parameter of the ReadDirectory method, and all other output parameters will be blank.

A value of zero is returned if the operation was successful, otherwise a non-zero error code is returned which indicates the cause of the failure.

Note that you must call the CloseDirectory method after the list of files has been returned by the server. Failure to do so will result in an error when you attempt to transfer a file because the data channel to the server has been left open. For this same reason, you cannot call the GetFile or PutFile methods while reading the contents of a directory on the server.

Example

' Request a parsed directory listing.
nError = FileTransfer1.OpenDirectory(strDirName)

' Request a parsed directory listing of the current directory
nError = FileTransfer1.OpenDirectory()

' Request an un-parsed listing of files in the current directory
nError = FileTransfer1.OpenDirectory("",False)

' Request a parsed listing of files in the current directory
' with file extension .exe
nError = FileTransfer1.OpenDirectory("*.exe")

See Also

CloseDirectory Method, ReadDirectory Method


Copyright © 2008 Catalyst Development Corporation. All rights reserved.