Directory is a data type that allows the management of system directories. It simplifies the development of applications that need to execute actions over system directories and files.
Use Directory data type for typical operations such as creating, copying, moving, renaming and deleting directories. You can also use the Directory data type to obtain the directory attributes such as modification date, time and size.
||Selects the directory in the specified path.
||Returns the result of the last operation. It has one of the following values:
0: Operation completed successfully.
1: Invalid directory instance - when the Source property was not set.
2: Directory does not exist.
3: Directory already exists.
4: Directory not empty.
100: Security error.
-1: Undefined error
||Returns the result description of the last operation
||The directory where files related to the application are stored.
||The directory where temporary files of the application are stored
||The path to the external storage device, if it exists, otherwise this property has the value of the property "ApplicationDataPath".
For more information about static properties of this data type please refer to Directory Data Type Static properties.
Creates a new directory in the specified source.
Directory name (character)
Deletes the source directory.
Checks whether the directory specified in source exists.
Msg("The directory exists!")
Msg("The directory does not exist!")
Returns the source directory's name.
&directory.Source = "c:\temp"
Msg(&directory.GetName()) // screen shows: temp
Returns the absolute name of the source directory.
Msg(&directory.GetAbsoluteName()) // screen shows: c:\temp
Renames the source directory. It can be also used to move the directory changing its current path.
The new name of the directory (Character).
Returns the names of files in the source directory. Also, a filter can be specified using extension-wildcards or end-with patterns.
for &auxFile in &directory.GetFiles('*.txt')
// do something with .txt auxFile
where &auxFile is defined as a File variable.
Returns the names of every directory in the source directory.
for &auxDir in &directory.GetDirectories()
// do something with auxDir
where &auxDir is defined as a Directory variable.
Directory data type handles directories that are in the local file system by default. But when it is returned by a method of the Storage Provider API, then it refers to a directory located in the external storage.
Let suppose we have a bucket named 'mytest' and a folder named 'petsFolder' created using Storage Provider API, and then use StorageAPI.GetDirectory(). Here is a list of the output of each method:
Refer to Storage Provider API for related sample code.
Mapped Drives and Network Drives are not supported in web environments