Is the File Name Wrong?

 

When open a file, get the error "5002".

Use "Print()" the file name,  got "C:\Users\900077605\AppData\Roaming\MetaQuotes\Terminal\3222703EF955C10T7523LJHO8922D2\Info.csv"

Could you please help tell what is the name problem? Thanks! 

 
Would you mind to read in the reference the explanation of FileOpen()?
 

Of course I've read it and I read it again now.

Maybe I've misunderstood something.

Could  you please just tell what's wrong?

 

Dears, who can help? I read again on the explanation and didn't find the root cause. 

But when I remove the path, it works. Does it mean I can't change the path to "D:\\temp"?

However, I believe it can change to other directory as it says "The name of the file can contain subfolders".  

Or any mis-understanding by me? Who can tell how to create a file under "D:\\temp"? Thanks a lot for support!

 

Did you read and understand:

Note
For security reasons, work with files is strictly controlled in the MQL4 language. 
Files with which file operations are conducted using MQL4 means, cannot be outside the file sandbox.
The file is opened in the folder of the client terminal in the subfolder MQL4\files (or Tester\Files in case of testing). 

Now compare your path to the path in the example(s).

 
gooly:

Did you read and understand:

Now compare your path to the path in the example(s).


Dear Gooly, thank you very much for help! 

 However, please refer to the example under FileOpen() as pasted below.

I copied it in my code and it doesn't work. Does it mean the example from MQL team isn't correct?  

   string terminal_data_path=TerminalInfoString(TERMINAL_DATA_PATH);
   string filename=terminal_data_path+"\\MQL4\\Files\\"+"fractals.csv";
   int filehandle=FileOpen(filename,FILE_WRITE|FILE_CSV);
 

1) Why do you use the example which is introduced:

//--- incorrect file opening method
   string terminal_data_path=TerminalInfoString(TERMINAL_DATA_PATH);
   string filename=terminal_data_path+"\\MQL4\\Files\\"+"fractals.csv";
   int filehandle=FileOpen(filename,FILE_WRITE|FILE_CSV);

and not the lines below:

//--- correct way of working in the "file sandbox"
   ResetLastError();
   filehandle=FileOpen("fractals.csv",FILE_WRITE|FILE_CSV);

???

By the way "my code [..] doesn't work":

My crystal ball felt down 2 weeks ago and now has a flaw, butI plan to go shopping at Diagon Alley. So at the moment I am very limited to help you :(

 
gooly:

1) Why do you use the example which is introduced:

and not the lines below:

???

By the way "my code [..] doesn't work":

My crystal ball felt down 2 weeks ago and now has a flaw, butI plan to go shopping at Diagon Alley. So at the moment I am very limited to help you :(

Dear Gooly, enjoy your shopping! Believe other friend can continue help. 
 
Dear MQL team, please refer to your example and help under FileOpen() as pasted below.

In fact, the file can't be opened with the absolute path. May I ask a favor for you to correct lest any confusion? 

 

 string terminal_data_path=TerminalInfoString(TERMINAL_DATA_PATH);
 string filename=terminal_data_path+"\\MQL4\\Files\\"+"fractals.csv";
 int filehandle=FileOpen(filename,FILE_WRITE|FILE_CSV);
 
jollydragon: May I ask a favor for you to correct lest any confusion?
 string terminal_data_path=TerminalInfoString(TERMINAL_DATA_PATH);
 string filename=terminal_data_path+"\\MQL4\\Files\\"+"fractals.csv";
 int filehandle=FileOpen(filename,FILE_WRITE|FILE_CSV);
what part of
//--- correct way of working in the "file sandbox"
   ResetLastError();
   filehandle=FileOpen("fractals.csv",FILE_WRITE|FILE_CSV);
was unclear?
 
What I pasted was copied from "help book" of MetaQuotes, which needs correcting.
Reason: