Download MetaTrader 5
To add comments, please log in or register
Do you have a trading signal? Publish it in your blog as well!
moonsboy
889
moonsboy 2014.11.18 06:34 

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
6392
Carl Schreiber 2014.11.18 06:38  
Would you mind to read in the reference the explanation of FileOpen()?
moonsboy
889
moonsboy 2014.11.18 06:48  

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 2014.11.18 09:09  

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
6392
Carl Schreiber 2014.11.18 10:47  

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 2014.11.19 03:13  
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
6392
Carl Schreiber 2014.11.19 10:55  

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 2014.11.20 02:57  
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 2014.11.20 03:00  
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
14236
whroeder1 2014.11.21 14:16  
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 2014.11.28 01:24  
What I pasted was copied from "help book" of MetaQuotes, which needs correcting.
/ /12
To add comments, please log in or register