File Library Object
The File library object functions enable you to read text from and write text to files, as well as manage files, folders, and directories.
The functions are exposed under Project > References > Library References > Direct.Shared.Library > File.
Copies the files in a source directory to a target directory. You can specify if the files should be overwritten if they already exist in the target directory.
| Parameter | Input | Description |
|---|---|---|
|
sourcedir |
Text |
The path to the source directory. |
|
targetdir |
Text |
The path to the target directory. |
|
override |
Boolean |
If the files should be overwritten if they already exist in the target directory. |
Returns
Returns true upon success.
Copies a file from a source directory to a target directory, and optionally renames it.
| Parameter | Input | Description |
|---|---|---|
|
File Name |
Text |
The name of the file to be copied, including the file extension. |
|
Path |
Text |
The path to the source directory. |
|
New Path |
Text |
The path to the target directory. |
|
New File Name |
Text |
The name of the file in the target directory, including the file extension. You can either use the original file name, or optionally rename the file. |
Returns
N/A
Creates a directory.
| Parameter | Input | Description |
|---|---|---|
|
directory |
Text |
The name and path of the new directory. |
Returns
Returns true upon success.
Deletes a directory. You can specify if all subdirectories should be deleted recursively.
| Parameter | Input | Description |
|---|---|---|
|
directory |
Text |
The name and path of the directory. |
|
recursively |
Boolean |
If all subdirectories should be deleted recursively. If the specified directory contains subdirectories and the value of this parameter is set as False, the directory will not be deleted. |
Returns
Returns true upon success.
Deletes a file.
| Parameter | Input | Description |
|---|---|---|
|
File Name and Path |
Text |
The name and path of the file, including the file extension. |
Returns
N/A
Checks if a directory exists.
| Parameter | Input | Description |
|---|---|---|
|
directory |
Text |
The name and path of the directory. |
Returns
Returns true if the specified directory exists.
Checks if a file exists.
| Parameter | Input | Description |
|---|---|---|
|
file name |
Text |
The name and path of the file, including the file extension. |
Returns
Return true if the specified file exists.
Returns a list of all the encodings available on the current environment. There are no parameters for this function.
Returns
Returns a List of Text. Each list item consists of three fields: Code Page, Name, and Full Name. For example:
Code Page: 1251, Name: Windows-1251, Full Name: Cyrillic (Windows)
Returns the file information for a file.
To use this function, create an instance of the File Information business entity and define the initial value of the FileName property as the file name and path, including the file extension. In the Get File Information function, use the File Information instance as the value of the File Info parameter. The function will retrieve the other file information properties (Accessed Time, Creation Time, Hidden, Modification Time, Read Only, Size, and Version) and populate the File Information instance.
Note: In RT Designer 7.2 and earlier, Accessed Time, Creation Time, and Modification Time is populated as Text. In RT Designer 7.3 and onwards, Time Accessed, Time Created, and Time Modified are added to populate these properties as DateTime.
| Parameter | Input | Description |
|---|---|---|
|
File Info |
File Information |
A File Information business entity instance for which the value of the FileName property has been defined as the name and path of the file, including the file extension. |
Returns
N/A
Returns the file information for the files in a folder. You can choose to return the file information for all files in the folder, or only return the file information for files with a specified extension.
| Parameter | Input | Description |
|---|---|---|
|
Extension |
Text |
The file extension. If the Extension is empty, this function gets the file information of all the files present in the specified folder. |
|
FolderPath |
Text |
The name and path of the folder. |
Returns
Returns a List of File Information.
Returns the file information for the files in a folder and all its subfolders. You can choose to return the file information for all files, or only return the file information for files with a specified extension.
| Parameter | Input | Description |
|---|---|---|
|
Extension |
Text |
The file extension. If the Extension is empty, this function gets the file information of all the files present in the specified folder and its subfolders. |
|
FolderPath |
Text |
The name and path of the folder. |
Returns
Returns a List of File Information.
Moves the files and subfolders from a specified source directory to a specified target directory, and deletes the source directory. You can specify if the files should be overwritten if they already exist in the target directory.
| Parameter | Input | Description |
|---|---|---|
|
directory |
Text |
The path to the source directory from which to move the files. |
|
newdir |
Text |
The path to the target directory to which to move the files. |
|
override |
Boolean |
If the files should be overwritten if they already exist in the target directory. |
Returns
Returns true upon success.
Moves a specified file from a specified source directory to a specified target directory.
| Parameter | Input | Description |
|---|---|---|
|
File Name |
Text |
The name of the file to be moved, including the file extension. |
|
Path |
Text |
The path to the source directory from which to move the file. |
|
New Path |
Text |
The path to the target directory to which to move the file. |
|
Overwrite |
Boolean |
If the file should be overwritten if it already exists in the target directory. |
Returns
N/A
Reads the textual content of a specified file.
| Parameter | Input | Description |
|---|---|---|
|
Path |
Text |
The path to the directory in which the file is found. |
|
File |
Text |
The name of the file, including the file extension. |
Returns
Returns the file text.
Reads the textual content of a specified file using the specified encoding.
| Parameter | Input | Description |
|---|---|---|
|
Path |
Text |
The path to the directory in which the file is found. |
|
File |
Text |
The name of the file, including the file extension. |
|
Code Page |
Number |
The Code Page number of the encoding you want to use to read the textual content of the file. |
Returns
Returns the file text.
Renames a specified directory to a specified name. You can specify if the directory should be overwritten if a directory with the new name already exists.
| Parameter | Input | Description |
|---|---|---|
|
directory |
Text |
The name and path of the directory you want to rename. |
|
newdir |
Text |
The new name for the directory, without the path. |
|
override |
Boolean |
If the directory should be overwritten if a directory with the new name already exists. |
Returns
Returns true upon success.
Renames a specified file.
| Parameter | Input | Description |
|---|---|---|
|
File Name |
Text |
The name of the file to be renamed, including the file extension. |
|
Path |
Text |
The path to the directory in which the file to be renamed is found. |
|
New File Name |
Text |
The new file name, including the file extension. |
Returns
N/A
Shows a Windows Open File or Save File dialog box, in which users can browse to and select a file. The function returns the name and full file path of the selected file.
| Parameter | Input | Description |
|---|---|---|
|
Title |
Text |
The text to be used as the title of the dialog box. |
|
Start File Name |
Text |
The full path of the file that should be selected when the dialog box opens. If you do not want to select a specific file, specify a folder path, and that folder will be selected when the dialog box opens. |
|
Filter File Types |
Text |
One or more of the following filters to be applied to the files in the dialog box : txt, docx, or exe. To apply multiple filters, separate them with semi-colons. Leave this parameter empty to show all files. |
| Save Mode | Boolean | Whether the function opens the Open File dialog box (False) or the Save File dialog box (True). |
Returns
The name and full file path of the selected file.
Opens a Windows Browse Folder dialog box, in which users can browse to and select a folder. The function returns the full path of the selected folder. For an example of working with this function, see Using the Show Browse for Folder Dialog Function.
| Parameter | Input | Description |
|---|---|---|
|
Title |
Text |
The text to be used as the title of the dialog box. |
|
Description |
Text |
The text to be used as a description at the top of the dialog box. |
|
Start Path |
Text |
The full path of the folder that should be selected when the dialog box opens. |
Returns
The full path of the selected folder.
Writes specified text to a specified file. If the file does not exist, it is created; otherwise, it is updated or overwritten as specified.
| Parameter | Input | Description |
|---|---|---|
|
Text |
Text |
The text to be written to the file. |
|
Path |
Text |
The path to the directory in which the file is found. |
|
File |
Text |
The name of the file to which you want to write the text, including the file extension. |
|
Update |
Boolean |
If the text should be added to any existing text in the file, or if existing text in the file should be overwritten with the new text. |
Returns
Returns true upon success.
Writes specified text to a specified file using specified encoding. If the file does not exist, it is created; otherwise, it is updated or overwritten as specified.
| Parameter | Input | Description |
|---|---|---|
|
Text |
Text |
The text to be written to the file. |
|
Path |
Text |
The path to the directory in which the file is found. |
|
File |
Text |
The name of the file to which you want to write the text, including the file extension. |
|
Code Page |
Number |
The Code Page number of the encoding you want to use to write the text to the file. |
|
Update |
Boolean |
If the text should be added to any existing text in the file, or if existing text in the file should be overwritten with the new text. |
Returns
Returns true upon success.
Compresses and stores the list of files present in a folder to a specified zip file.
| Parameter | Input | Description |
|---|---|---|
|
List of Files with Path |
Text |
The list of files to be compressed and stored. All the files to be compressed must be placed in the same folder. To compress all the files in a folder, you must provide the folder path only. The subfolders inside the given folder will also be compressed. |
|
File Name with Path |
Text |
Name of the target zip file along with the file path. |
|
Timeout |
Number |
The timeout value, between 1 and 10 (minutes). |
Returns
Returns true upon success.