Skip to main content
Version: v20 R4 BETA

Directory Class

.creationDate

History
VersionChanges
v17 R5Added

.creationDate : Date

Description

The .creationDate property returns the creation date of the folder.

This property is read-only.


.creationTime

History
VersionChanges
v17 R5Added

.creationTime : Time

Description

The .creationTime property returns the creation time of the folder (expressed as a number of seconds beginning at 00:00).

This property is read-only.


.exists

History
VersionChanges
v17 R5Added

.exists : Boolean

Description

The .exists property returns true if the folder exists on disk, and false otherwise.

This property is read-only.


.extension

History
VersionChanges
v17 R5Added

.extension : Text

Description

The .extension property returns the extension of the folder name (if any). An extension always starts with ".". The property returns an empty string if the folder name does not have an extension.

This property is read-only.


.fullName

History
VersionChanges
v17 R5Added

.fullName : Text

Description

The .fullName property returns the full name of the folder, including its extension (if any).

This property is read-only.


.hidden

History
VersionChanges
v17 R5Added

.hidden : Boolean

Description

The .hidden property returns true if the folder is set as "hidden" at the system level, and false otherwise.

This property is read-only.


.isAlias

History
VersionChanges
v17 R5Added

.isAlias : Boolean

Description

The .isAlias property returns always false for a Folder object.

This property is read-only.


.isFile

History
VersionChanges
v17 R5Added

.isFile : Boolean

Description

The .isFile property returns always false for a folder.

This property is read-only.


.isFolder

History
VersionChanges
v17 R5Added

.isFolder : Boolean

Description

The .isFolder property returns always true for a folder.

This property is read-only.


.isPackage

History
VersionChanges
v17 R5Added

.isPackage : Boolean

Description

The .isPackage property returns true if the folder is a package on macOS (and exists on disk). Otherwise, it returns false.

On Windows, .isPackage always returns false.

This property is read-only.


.modificationDate

History
VersionChanges
v17 R5Added

.modificationDate : Date

Description

The .modificationDate property returns the date of the folder's last modification.

This property is read-only.


.modificationTime

History
VersionChanges
v17 R5Added

.modificationTime : Time

Description

The .modificationTime property returns the time of the folder's last modification (expressed as a number of seconds beginning at 00:00).

This property is read-only.


.name

History
VersionChanges
v17 R5Added

.name : Text

Description

The .name property returns the name of the folder, without extension (if any).

This property is read-only.


.original

History
VersionChanges
v17 R5Added

.original : 4D.Folder

Description

The .original property returns the same Folder object as the folder.

This property is read-only.

This property is available on folders to allow generic code to process folders or files.


.parent

History
VersionChanges
v17 R5Added

.parent : 4D.Folder

Description

The .parent property returns the parent folder object of the folder. If the path represents a system path (e.g., "/DATA/"), the system path is returned.

If the folder does not have a parent (root), the null value is returned.

This property is read-only.


.path

History
VersionChanges
v17 R5Added

.path : Text

Description

The .path property returns the POSIX path of the folder. If the path represents a filesystem (e.g., "/DATA/"), the filesystem is returned.

This property is read-only.


.platformPath

History
VersionChanges
v17 R5Added

.platformPath : Text

Description

The .platformPath property returns the path of the folder expressed with the current platform syntax.

This property is read-only.


.copyTo()

History
VersionChanges
v17 R5Added

.copyTo( destinationFolder : 4D.Folder { ; newName : Text } { ; overwrite : Integer } ) : 4D.Folder

ParameterTypeDescription
destinationFolder4D.Folder->Destination folder
newNameText->Name for the copy
overwriteInteger->fk overwrite to replace existing elements
Result4D.Folder<-Copied file or folder

Description

The .copyTo() function copies the Folder object into the specified destinationFolder.

The destinationFolder must exist on disk, otherwise an error is generated.

By default, the folder is copied with the name of the original folder. If you want to rename the copy, pass the new name in the newName parameter. The new name must comply with naming rules (e.g., it must not contain characters such as ":", "/", etc.), otherwise an error is returned.

If a folder with the same name already exists in the destinationFolder, by default 4D generates an error. You can pass the fk overwrite constant in the overwrite parameter to ignore and overwrite the existing file

ConstantValueComment
fk overwrite4Overwrite existing elements, if any

Returned value

The copied Folder object.

Example

You want to copy a Pictures folder from the user's Document folder to the Database folder:

var $userImages; $copiedImages : 4D.Folder
$userImages:=Folder(fk documents folder).folder("Pictures")
$copiedImages:=$userImages.copyTo(Folder(fk database folder);fk overwrite)

.file()

History
VersionChanges
v17 R5Added

.file( path : Text ) : 4D.File

ParameterTypeDescription
pathText->Relative POSIX file pathname
Result4D.File<-File object (null if invalid path)

Description

The .file() function creates a File object inside the Folder object and returns its reference.

In path, pass a relative POSIX path to designate the file to return. The path will be evaluated from the parent folder as root.

Returned value

A File object or null if path is invalid.

Example

var $myPDF : 4D.File
$myPDF:=Folder(fk documents folder).file("Pictures/info.pdf")

.files()

History
VersionChanges
v17 R5Added

.files( { options : Integer } ) : Collection

ParameterTypeDescription
optionsInteger->File list options
ResultCollection<-Collection of children file objects

Description

The .files() function returns a collection of File objects contained in the folder.

Aliases or symbolic links are not resolved.

By default, if you omit the options parameter, only the files at the first level of the folder are returned in the collection, as well as invisible files or folders. You can modify this by passing, in the options parameter, one or more of the following constants:

ConstantValueComment
fk recursive1The collection contains files of the specified folder and its subfolders
fk ignore invisible8Invisible files are not listed

Returned value

Collection of File objects.

Example 1

You want to know if there are invisible files in the Database folder:

 var $all; $noInvisible : Collection
$all:=Folder(fk database folder).files()
$noInvisible:=Folder(fk database folder).files(fk ignore invisible)
If($all.length#$noInvisible.length)
ALERT("Database folder contains hidden files.")
End if

Example 2

You want to get all files that are not invisible in the Documents folder:

 var $recursive : Collection
$recursive:=Folder(fk documents folder).files(fk recursive+fk ignore invisible)

.folder()

History
VersionChanges
v17 R5Added

.folder( path : Text ) : 4D.Folder

ParameterTypeDescription
pathText->Relative POSIX file pathname
Result4D.Folder<-Created folder object (null if invalid path)

Description

The .folder() function creates a Folder object inside the parent Folder object and returns its reference.

In path, pass a relative POSIX path to designate the folder to return. The path will be evaluated from the parent folder as root.

Returned value

A Folder object or null if path is invalid.

Example

 var $mypicts : 4D.Folder
$mypicts:=Folder(fk documents folder).folder("Pictures")

.folders()

History
VersionChanges
v17 R5Added

.folders( { options : Integer } ) : Collection

ParameterTypeDescription
optionsInteger->Folder list options
ResultCollection<-Collection of children folder objects

Description

The .folders() function returns a collection of Folder objects contained in the parent folder.

By default, if you omit the options parameter, only the folders at the first level of the folder are returned in the collection. You can modify this by passing, in the options parameter, one or more of the following constants:

ConstantValueComment
fk recursive1The collection contains folders of the specified folder and its subfolders
fk ignore invisible8Invisible folders are not listed

Returned value

Collection of Folder objects.

Example

You want the collection of all folders and subfolders of the database folder:

 var $allFolders : Collection
$allFolders:=Folder("/PACKAGE").folders(fk recursive)

.getIcon()

History
VersionChanges
v17 R5Added

.getIcon( { size : Integer } ) : Picture

ParameterTypeDescription
sizeInteger->Side length for the returned picture (pixels)
ResultPicture<-Icon

Description

The .getIcon() function returns the icon of the folder.

The optional size parameter specifies the dimensions in pixels of the returned icon. This value actually represents the length of the side of the square containing the icon. Icons are usually defined in 32x32 pixels ("large icons") or 16x16 pixels ("small icons"). If you pass 0 or omit this parameter, the "large icon" version is returned.

If the folder does not exist on disk, a default blank icon is returned.

Returned value

Folder icon picture.