FileOpen location

 

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

Documentation on MQL5: File Functions / FileOpen
Documentation on MQL5: File Functions / FileOpen
  • www.mql5.com
File Functions / FileOpen - Documentation on MQL5
 

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
  • www.mql5.com
Standard Constants, Enumerations and Structures / Input/Output Constants / File Opening Flags - Documentation on MQL5
 
jshumaker:

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

See here if it can help you.
 

this is a useful code but i do not know how to use it.thanks share
 

C:\Users\jeff\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\MQL5\Files

 I checked that directory and I still do not see any files.   

 
never mind i finally found the stupid file in c:\programdata
 

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.

 
jshumaker:

C:\Users\jeff\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\MQL5\Files

 I checked that directory and I still do not see any files.   

It won't go there when you use the common flag.
Reason: