FolderItem.Child

From Xojo Documentation

Method

FolderItem.Child(name As String, followAlias As Boolean = True) As FolderItem

Supported for all project types and targets.

Returns a FolderItem that represents a file or folder/directory within this FolderItem with the matching name or index passed.

Notes

Shortcuts and aliases are resolved on all platforms when followAlias is True.

Returns Nil only when some portion of the path to the child does not exist. For example:

SpecialFolder.System.Child("Yummy").Child("Cake")

will return Nil if:

  • SpecialFolder.System is nil or does not exist
  • the folder/directory "Yummy" does not exist

Raises UnsupportedFormatException if Name is blank.

Example

Var docFile As FolderItem = SpecialFolder.Desktop.Child("Docs").Child("Current").Child("MyFile.txt")

Trying to access a path where several components of the path do not exist may cause a NilObjectException The above code will do this if :

  • the folder Docs does not exist on the desktop
  • the folder Current does not exist inside folder Docs
  • and the file MyFile.txt does not exist