Get File Info
The Get File Info action (screenshot below) adds information about the specified file (or folder) to a page source called $MT_FILEINFO. An $MT_FILEINFO page source is created either when a Read Folder action or a Get File Info action is added to the design, whichever is added first. In the settings of the action, select the file about which you want to get info.
Note that there is only one $MT_FILEINFO page source per page. So, if multiple Get File Info actions are triggered during the processing of a page at run time, then $MT_FILEINFO at any given time will contain information from the last Get File Info action that was triggered.
Structure of the $MT_FILEINFO tree
The structure the $MT_FILEINFO tree is as shown in the screenshot below. The Root element has a number of attributes that will be filled with the file information of the file specified in the triggered action. Descriptions of the attributes are given below.
•Path: The full path of the file being reported.
•Size: The file size In bytes.
•CreationTime: The time when the file was created at its current location. If a file is copied to a new location, then the time at which it was copied will be the creation time. In such cases, the creation time could be later than the WriteTime.
•AccessTime: The time when the file was last accessed.
•WriteTime: The time when the file was last written to.
•IsDirectory: Can take a value of true or false.
•IsReadOnly: Can take a value of true or false.
Note: | The data read by the Get File Info action is passed to the attributes of $MT_FILEINFO/Root (as described above). The $MT_FILEINFO/Root node, however, also has child elements: repeating File elements, which receive data via another action, Read Folder. The Read Folder action fills the File elements with metadata about files in a specified folder. |
Example
An example file named ReadFolderGetFileInfo.mtd shows how to use the Get Info action (see screenshot of simulation below). This file is available in the (My) Documents folder Altova\MobileTogetherDesigner10\MobileTogetherDesignerExamples\Tutorials\Actions.
The example works as follows:
•The end user enters the name of a file in the edit field to the left of the Get File Info button.
•The file name is written to the Root/File node of the $PERSISTENT tree (see screenshot).
•The Get File Info button has a Get File Info action set for its OnButtonClick event that targets the file (or folder) stored in $PERSISTENT/Root/File.
•On clicking Get File Info, the information of the targeted file is read and passed to the $MT_FILEINFO page source as the values of the attributes of $MT_FILEINFO/Root.
•These attribute values are displayed in the cells of a static table.
MobileTogether extension functions
MobileTogether provides a range of XPath extension functions that have been specifically created for use in MobileTogether designs. Some functions can be particularly useful with specific actions. For example, mt-available-languages() returns the languages in which the solution is available and could, for example, be used with the Message Box action. If a function is especially relevant to this action, it is listed below. For a full list of extension functions and their descriptions, see the topic MobileTogether Extension Functions.
mt-cache-update-dateTime()
mt-extract-file-extension()
mt-extract-file-name()