FileOpen error 5002

 

Hello,

have problem with writing file from within OnTest


    string terminal_data_path=TerminalInfoString(TERMINAL_DATA_PATH);
    string filename=terminal_data_path+"\\MQL5\\Files\\"+"mytest.csv";
    
    int filehandle=FileOpen(filename,FILE_WRITE|FILE_CSV);
    if(filehandle<0)
    {
        Print("Failed to open the file by the absolute path "+filename);
        Print("Error code ",GetLastError());
    }

filehandle=5002

 

From journal 

2012.07.25 23:16:00 Core 1 2012.07.23 23:59:59   Failed to open the file by the absolute path C:\Users\general\AppData\Roaming\MetaQuotes\Tester\B2816E90C35C2BD793EFA45DDB08414F\Agent-127.0.0.1-3000\mytest.csv

 

The path

 C:\Users\general\AppData\Roaming\MetaQuotes\Tester\B2816E90C35C2BD793EFA45DDB08414F\Agent-127.0.0.1-3000

exists but no file in it.

 

Anyone knows what's going on ? 

Thank you 

 

SOLVED. Please apologize this post. Within the sandbox, no absolute path accepted. Do it this way:

string terminal_data_path=TerminalInfoString(TERMINAL_DATA_PATH);
    string filename="mytest.csv";
    
    int filehandle=FileOpen(filename,FILE_WRITE|FILE_CSV);
    if(filehandle<0)
    {
        Print("Failed to open the file by the absolute path "+filename);
        Print("Error code ",GetLastError());
    }

 In my case file is written to:

 

 C:\Users\general\AppData\Roaming\MetaQuotes\Tester\B2816E90C35C2BD793EFA45DDB08414F\Agent-127.0.0.1-3000 

Reason: