DirTree DataFlex Reference Documentation
DirTree
Current Version: 11.5.0
Chilkat.DirTree
Iterate through the contents of a base directory, either recursively or
one level at a time.
Get the current item's full path, relative path, UNC path, size, and
directory/file status.
Traverse entire directory trees when an application needs to process all
nested files and folders.
Limit iteration to the immediate contents of the base directory when
deeper traversal is not needed.
Use absolute or relative paths depending on whether the application needs
filesystem access or archive-style relative names.
Use
For an extended overview, see
DirTree Class Overview.
Iterate through files and subdirectories under a base directory.
Chilkat.DirTree is a lightweight directory-tree iterator for
traversing files and subdirectories under a selected base directory. It
supports recursive and non-recursive traversal and exposes useful information
about the current item, including absolute path, UNC path, relative path,
file size, and whether the current item is a directory.
Directory traversal
Current-item details
Recursive scanning
Non-recursive listing
Path-friendly output
Error-aware iteration
DoneIterating to distinguish normal completion from an
error when an iteration method returns false.
DoneIterating when iteration stops to determine whether traversal
completed normally or ended because of an error.
Object Creation
// (Dataflex programs use the 32-bit Chilkat ActiveX) Handle hoDirTree
Get Create(RefClass(cComCkDirTree)) to hoDirTree
Properties
BaseDir
Procedure Set ComBaseDir String value
DebugLogFilePath
Procedure Set ComDebugLogFilePath String value
If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. This logging helps identify the context and history of Chilkat calls leading up to any crash or hang, aiding in debugging.
Enabling the VerboseLogging property provides more detailed information. This property is mainly used for debugging rare instances where a Chilkat method call causes a hang or crash, which should generally not happen.
Possible causes of hangs include:
- A timeout property set to 0, indicating an infinite timeout.
- A hang occurring within an event callback in the application code.
- An internal bug in the Chilkat code causing the hang.
DoneIterating
Set to True when the last file or sub-directory has been iterated.
FileSize32
The file size of the current file in the iteration. (0 if it is a directory.)
topFileSizeStr
The file size of the current file in the iteration as a decimal string. (0 if it is a directory.)
topFullPath
The absolute directory path of the current file or sub-directory.
topFullUncPath
The absolute UNC directory path of the current file or sub-directory.
topIsDirectory
True if the current position is a sub-directory, False if it is a file.
LastBinaryResult
This property is mainly used in SQL Server stored procedures to retrieve binary data from the last method call that returned binary data. It is only accessible if Chilkat.Global.KeepBinaryResult is set to True. This feature allows for the retrieval of large varbinary results in an SQL Server environment, which has restrictions on returning large data via method calls, though temp tables can handle binary properties.
LastErrorHtml
Provides HTML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.
topLastErrorText
Provides plain text information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.
LastErrorXml
Provides XML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.
topLastMethodSuccess
Procedure Set ComLastMethodSuccess Boolean value
Indicates the success or failure of the most recent method call: True means success, False means failure. This property remains unchanged by property setters or getters. This method is present to address challenges in checking for null or Nothing returns in certain programming languages. Note: This property does not apply to methods that return integer values or to boolean-returning methods where the boolean does not indicate success or failure.
LastStringResult
In SQL Server stored procedures, this property holds the string return value of the most recent method call that returns a string. It is accessible only when Chilkat.Global.KeepStringResult is set to TRUE. SQL Server has limitations on string lengths returned from methods and properties, but temp tables can be used to access large strings.
LastStringResultLen
The length, in characters, of the string contained in the LastStringResult property.
topRecurse
Procedure Set ComRecurse Boolean value
If True, the iteration will be recursive. If False the iteration is non-recursive. The default value is True.
RelativePath
The relative directory path of the current file or sub-directory. (Relative to the BaseDir)
topUncommonOptions
Procedure Set ComUncommonOptions String value
This is a catch-all property to be used for uncommon needs. This property defaults to the empty string, and should typically remain empty.
Q_EncodePathsAdded inv11.1.0. Return file paths Q-Encoded.
VerboseLogging
Procedure Set ComVerboseLogging Boolean value
If set to True, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. The default value is False. Verbose logging should only be used for debugging. The potentially large quantity of logged information may adversely affect peformance.
Version
Methods
AdvancePosition
Advances the current position in the directory tree traversal to the next file or sub-directory.
Important: If AdvancePosition returns False, it can be an error, or it could be that there are no more files and directories. To distinguish between the two cases, examine the DoneIterating property. If DoneIterating is True, then the False return value is not an error, but instead indicates that the end has been reached.
Returns True for success, False for failure.
BeginIterate
Begins a directory tree traversal. After calling this method, the various property values such as Fullpath, FileSize32, etc. can be retrieved for the 1st file / sub-directory in the traversal.
Important: If BeginIterate returns False, it can be an error, or it could be that there are 0 files and directories. To distinguish between the two cases, examine the DoneIterating property. If DoneIterating is True, then the False return value is not an error, but instead indicates 0 files/directories.
Returns True for success, False for failure.
top