From Xojo Documentation
Returns a FolderItem that represents a file or directory within this FolderItem with the name Name.
Shortcuts and aliases are resolved on all platforms.
Returns Nil only when some portion of the path to the child does not exist. For example:
will return Nil if:
- SpecialFolder.System is nil or does not exist
- the directory "Yummy" does not exist
Raises UnsupportedFormatException if Name is blank.
f = New FolderItem
g = f.GetRelative(f.GetSaveInfo(Volume(0).Child("Documents"), 0))
If g <> Nil Then
Label2.Text = g.NativePath
MsgBox("FolderItem does not exist!")
Trying to access a path where several components of the path do not exist may cause a NilObjectException The following code will do this if :
- the directory foo does not exist on the desktop
- the directory bar does not exist inside directory foo
- and the file somefile does not exist
It does this because
- SpecialFolder.Desktop works and returns a valid non-nil folderitem
- SpecialFolder.Desktop.Child("foo") returns a valid but non-existing folder item (this would allow you to create items that do not exist)
- SpecialFolder.Desktop.Child("foo").child("bar") returns nil
- SpecialFolder.Desktop.Child("foo").child("bar").child("somefile") now tries to use a NIL item to access the file and this causes the NilObjectException