|
File Functions
This is a group of functions for working with files.
For security reasons, work with files is strictly controlled in the MQL5 language. Files with which file operations are conducted using MQL5 means cannot be outside the file sandbox.
There are two directories (with subdirectories) in which working files can be located:
There is a program method to obtain names of these catalogs using the TerminalInfoString() function, using the ENUM_TERMINAL_INFO_STRING enumeration:
//--- Folder that stores the terminal data
|
Work with files from other directories is prohibited.
If the file is opened for writing using FileOpen(), all subfolders specified in the path will be created if there are no such ones.
File functions allow working with so-called "named pipes". To do this, simply call FileOpen() function with appropriate parameters.
Function |
Action |
---|---|
Create a file or folder opening/creation dialog |
|
Starts the search of files in a directory in accordance with the specified filter |
|
Continues the search started by the FileFindFirst() function |
|
Closes search handle |
|
Opens a file with a specified name and flag |
|
Deletes a specified file |
|
Writes to a disk all data remaining in the input/output file buffer |
|
Gets an integer property of a file |
|
Defines the end of a file in the process of reading |
|
Defines the end of a line in a text file in the process of reading |
|
Closes a previously opened file |
|
Checks the existence of a file |
|
Copies the original file from a local or shared folder to another file |
|
Moves or renames a file |
|
Reads arrays of any type except for string from the file of the BIN type |
|
Reads from the file of the CSV type a string from the current position till a delimiter (or till the end of a text line) and converts the read string to a value of bool type |
|
Reads from the file of the CSV type a string of one of the formats: "YYYY.MM.DD HH:MM:SS", "YYYY.MM.DD" or "HH:MM:SS" - and converts it into a datetime value |
|
Reads a double value from the current position of the file pointer |
|
Reads a float value from the current position of the file pointer |
|
Reads int, short or char value from the current position of the file pointer |
|
Reads a long type value from the current position of the file pointer |
|
Reads from the file of the CSV type a string from the current position till a delimiter (or til the end of a text line) and converts the read string into double value |
|
Reads a string from the current position of a file pointer from a file |
|
Reads the contents from a binary file into a structure passed as a parameter, from the current position of the file pointer |
|
Moves the position of the file pointer by a specified number of bytes relative to the specified position |
|
Returns the size of a corresponding open file |
|
Returns the current position of the file pointer of a corresponding open file |
|
Writes data to a file of CSV or TXT type |
|
Writes arrays of any type except for string into a file of BIN type |
|
Writes value of the double type from the current position of a file pointer into a binary file |
|
Writes value of the float type from the current position of a file pointer into a binary file |
|
Writes value of the int type from the current position of a file pointer into a binary file |
|
Writes value of the long type from the current position of a file pointer into a binary file |
|
Writes the value of a string parameter into a BIN or TXT file starting from the current position of the file pointer |
|
Writes the contents of a structure passed as a parameter into a binary file, starting from the current position of the file pointer |
|
Reads all data of a specified binary file into a passed array of numeric types or simple structures |
|
Writes to a binary file all elements of an array passed as a parameter |
|
Creates a folder in the Files directory |
|
Removes a selected directory. If the folder is not empty, then it can't be removed |
|
Deletes all files in the specified folder |