here is the code
int hfile;
hfile=FileOpen("h1.csv",FILE_WRITE|FILE_CSV|FILE_COMMON,'|');
if (hfile==INVALID_HANDLE)
{printf("invalid file");}
FileWrite(hfile,"test");
FileClose(hfile);

- www.mql5.com
According to this link, https://www.mql5.com/en/docs/files/fileopen, if I use FileOpen my file should be created under my MQL5\files\ directory, but I do not have a files directory. Under \MQL5 I have \experts, \images, \include, \indicators, \scripts. I am not getting an error from an invalid handle and yet I cannot find the file.
MQL5 directory = C:\Program Files\MetaTrader 5\MQL5
this is a useful code but i do not know how to use it.thanks share
The uncool thing about MT5 on Linux is that the files folder is in
Program Files/MetaTrader 5/Tester/Agent-127.0.0.1-3000/MQL5/Files/
and that this folder gets all of its file deleted every time the strategy tester gets run. Which means you have to copy the file to the folder all the time,
Also I managed to get the file read but the contents is completely garbage.
On MT4 the code worked perfectly as expected.
EDIT: I had to chown root of a subdir "Data" and add FILE_ANSI to the flags:
int file_handle=FileOpen(InpFileName,FILE_READ|FILE_TXT|FILE_ANSI);
and then it worked.
C:\Users\jeff\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\MQL5\Files
I checked that directory and I still do not see any files.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
According to this link, https://www.mql5.com/en/docs/files/fileopen, if I use FileOpen my file should be created under my MQL5\files\ directory, but I do not have a files directory. Under \MQL5 I have \experts, \images, \include, \indicators, \scripts. I am not getting an error from an invalid handle and yet I cannot find the file.
MQL5 directory = C:\Program Files\MetaTrader 5\MQL5