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);
![Documentation on MQL5: Standard Constants, Enumerations and Structures / Input/Output Constants / File Opening Flags Documentation on MQL5: Standard Constants, Enumerations and Structures / Input/Output Constants / File Opening Flags](/i/community/logo_mql5_small.png)
- 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.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- 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