Directory data type

Official Content

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.

Properties

Source  Selects the directory in the specified path.
ErrCode 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
ErrDescription   Returns the result description of the last operation

 

Static properties

ApplicationDataPath   The directory where files related to the application are stored.
TemporaryFilesPath The directory where temporary files of the application are stored
ExternalFilesPath 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.

 

Methods

Create

Creates a new directory in the specified source.

Parameters

Directory name (character)

Example
&directory.Source="c:\temp"
&directory.create()

Delete

Deletes the source directory.

Example
&directory.delete()

Exists

Checks whether the directory specified in source exists.

Returned values

Boolean

Example
If &directory.exists() 
    Msg("The directory exists!")
Else
    Msg("The directory does not exist!")
EndIf

GetName

Returns the source directory's name.

Returned values

Character

Example
&directory.Source = "c:\temp"
Msg(&directory.GetName()) // screen shows: temp

GetAbsoluteName

Returns the absolute name of the source directory.

Returned values

Character

Example
&directory.Source="c:\temp"
Msg(&directory.GetAbsoluteName()) // screen shows: c:\temp

Rename

Renames the source directory. It can be also used to move the directory changing its current path.

Parameters

The new name of the directory (Character).

Example
&directory.Rename("d:\temp2")

GetFiles

Returns the names of files in the source directory. Also, a filter can be specified using extension-wildcards or end-with patterns.

Parameters

Filter (Character)

Example
for &auxFile in &directory.GetFiles('*.txt')
   // do something with .txt auxFile         
endfor

where &auxFile is defined as a File variable.

GetDirectories

Returns the names of every directory in the source directory.

Example
for &auxDir in &directory.GetDirectories()
  // do something with auxDir
endfor

where &auxDir is defined as a Directory variable.

Directory Data Type and External Storage

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. 

Examples when using 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:

Method Returns
GetName petsFolder
GetAbsoluteName   mytest:\petsFolder\ 

Refer to Storage Provider API for related sample code.

Restrictions

Mapped Drives and Network Drives are not supported in web environments

See Also

Scope

Platforms  Web(.NET, Java), Smart Devices (Android Smart DevicesApple Smart Devices (iOS))
Objects Procedure object, Web Panel object, Transaction objectSmart Devices objects


Was this page helpful?
What Is This?
Your feedback about this content is important. Let us know what you think.