Directory Data Type Static properties

Official Content
This documentation is valid for:

GeneXus has specific data types such as Directory and File that allow working directly with the file system. However, in Smart Devices several restrictions exist in relation to which directories can be manipulated by the application, either in Apple or Android smart devices.

The Directory data type has 3 static, read-only properties which help the developer to work with the file system in Smart Devices and Web/Win applications.

ApplicationDataPath

The directory where the files related to the application are stored.

In iOS offline applications, this path matches the “Documents” folder path inside the application.

In Android offline applications, this path matches the “Private Storage” folder path of the application.

For the other generators (Web or Win) this path matches the “%USERPROFILE%” directory.

TemporaryFilesPath

The directory where temporary files of the application are stored.

For offline applications, either iOS or Android, files and folders in this directory may be removed by the operating system. In addition, it is important for the developer to check if these files or directories have been correctly removed.

For the other generators (Web or Win) this path matches the “%TEMP%” directory.

ExternalFilesPath

The path to the external storage device, if it exists; otherwise, this property has the value of the property "ApplicationDataPath".

In iOS, because there are no devices with external storage, this property has the same value as the “ApplicationDataPath” property. The same happens to Android devices when they don't have an external storage device.

Considerations

File separator at the end of the paths

All these properties do NOT include the file separator character at the end of the path. Therefore, the developer has to include it by using the Separator method of the File data type.

Server-side events

In smart device applications with Online architecture, the Start, Refresh and Load events run on the server-side. Therefore, if these properties are used in these events, their values will use the server property values mentioned above. See Server-side Events in Smart Devices for more information.

Relative paths

If the specified path is relative, the default directory is “Directory.ApplicationDataPath”.

Therefore, this line of code:

&file.Source = "someFile.txt"

… is equal to this line of code:

&file.Source = Directory.ApplicationDataPath + &file.Separator + "someFile.txt"

Absolute paths

In Android Smart Devices, absolute paths are supported and they always start with the character “/”. For instance:

&file.Source = "/sdcard/image.jpg"

In iOS Smart Devices, absolute paths are not supported by the platform.

Platform-specific paths

In iOS, access is supported to the directory where the KB images are located by using a variable path called “$RESOURCES”. For example, if the Knowledge Base has an image called “MyImage.png”, you can use this stub of code to use the image:

&file.Source = "$RESOURCES/MyImage.png"
&destPath = Directory.TemporaryFilesPath + &file.Separator + "MyImageCopy.png"
&file.Copy(&destPath)

Availability

These properties are available as from GeneXus X Evolution 3.

See also





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