Problem with reading and write data to txt

 

Hello,


I want to transfer data from demo to live account. This can be done with txt. I need small data for that,

but problem is because I have tried to use read and write to specific folder but my code not works.

How to do this?


 //--- open the file
   ResetLastError();
   int file_handle=FileOpen("D:\\44\\"+"44.txt",FILE_READ|FILE_BIN|FILE_ANSI);
   if(file_handle!=INVALID_HANDLE)
     {
      PrintFormat("%s file is available for reading","44.txt");
      PrintFormat("File path: %s\\Files\\",TerminalInfoString(TERMINAL_DATA_PATH));
      //--- additional variables
      int    str_size;
      string str;
      //--- read data from the file
      while(!FileIsEnding(file_handle))
        {
         //--- find out how many symbols are used for writing the time
         str_size=FileReadInteger(file_handle,INT_VALUE);
         //--- read the string
         str=FileReadString(file_handle,str_size);
         //--- print the string
         PrintFormat(str);
        }
      //--- close the file
      FileClose(file_handle);
      PrintFormat("Data is read, %s file is closed","44.txt");
     }
   else
      PrintFormat("Failed to open %s file, Error code = %d","44.txt",GetLastError())
 
Dejan Krapez:

Hello,


I want to transfer data from demo to live account. This can be done with txt. I need small data for that,

but problem is because I have tried to use read and write to specific folder but my code not works.

How to do this?


Double Click on FileOpen() and press F1. Zite (from the doc, you've hopefully just opened ;) : 

"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."

That means in short: You have to stay with your txt-files inside the <Terminal-dir>\MQL\files - dir (but you may create dirs below as you like).

Reason: