Download MetaTrader 5

Is the File Name Wrong?

To add comments, please log in or register
moonsboy
889
moonsboy  

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! 

Carl Schreiber
6692
Carl Schreiber  
Would you mind to read in the reference the explanation of FileOpen()?
moonsboy
889
moonsboy  

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?

moonsboy
889
moonsboy  

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!

Carl Schreiber
6692
Carl Schreiber  

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

moonsboy
889
moonsboy  
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);
Carl Schreiber
6692
Carl Schreiber  

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 :(

moonsboy
889
moonsboy  
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. 
moonsboy
889
moonsboy  
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);
whroeder1
14781
whroeder1  
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?
moonsboy
889
moonsboy  
What I pasted was copied from "help book" of MetaQuotes, which needs correcting.
12
To add comments, please log in or register