Download MetaTrader 5

File Reading Writing

To add comments, please log in or register
Having troubles understanding the code? Articles can help you!
SteelAce
180
SteelAce 2016.05.12 08:39 

In MQL5 Reference -> File Functions -> FileOpen is sample what is in this letter attachment as Sample.mq5. When you run that sample you can see that file can be written only when you give part of file path (last part of that Sample.mq5). When you give full path then file writing is unsuccessful even in that Sample.mq5 [Error code 5002 (: Invalid file name)]. In that case filename is "C:\Program Files\MetaTrader 5 Admiral Markets UK Ltd\MQL5\Files\fractals.csv" found by TerminalInfoString(TERMINAL_DATA_PATH) (Sample.mq5) . I don't understand how it can be wrong?

Files:
Sample.mq5 3 kb
ReadFile.mq5 29 kb
WriteFile.mq5 30 kb
Doerk Hilger
1155
Doerk Hilger 2016.05.13 00:50  
because you are using the non-working example as reference. You deal with absolute paths, that does not work. 
SteelAce
180
SteelAce 2016.05.13 00:52  
SteelAce:

In MQL5 Reference -> File Functions -> FileOpen is sample what is in this letter attachment as Sample.mq5. When you run that sample you can see that file can be written only when you give part of file path (last part of that Sample.mq5). When you give full path then file writing is unsuccessful even in that Sample.mq5 [Error code 5002 (: Invalid file name)]. In that case filename is "C:\Program Files\MetaTrader 5 Admiral Markets UK Ltd\MQL5\Files\fractals.csv" found by TerminalInfoString(TERMINAL_DATA_PATH) (Sample.mq5) . I don't understand how it can be wrong?

Problem is that files are (as if) possible to read-write only in directory ...\Files (and without giving full path of filename) but I need to Read-Write file on another drive, for exampe on drive D:\
Marco vd Heijden
Moderator
4704
Marco vd Heijden 2016.05.13 07:41  
SteelAce:
Problem is that files are (as if) possible to read-write only in directory ...\Files (and without giving full path of filename) but I need to Read-Write file on another drive, for exampe on drive D:\
You can not go outside of the terminal directory.
To add comments, please log in or register