Download MetaTrader 5
To add comments, please log in or register
Join MQL5 Cloud Network. Start earning money!
peterhw
69
peterhw 2016.11.09 16:24 

I have the following error in my own log file.

My_error: 5002 wrong file name My_FileRead_Handle =0, fname = C:\Users\user\AppData\Roaming\MetaQuotes\Terminal\9ACB2E2CE0389240C909714389C79575\logs\20161108.log

The file appears to be where I think it should be and the error occurs when I use the FileExists statement

 

fname above is put together using code below where is this case fname starts as  20161108

terminal_data_path=TerminalInfoString(TERMINAL_DATA_PATH)+"\\logs\\";

fname = terminal_data_path+fname+".log";

 I've spent quite sometime trying to locate this file - any ideas (I want to find a 'signal' in the log issued by an indicator)

InvestSoft
8355
Janusz Trojca 2016.11.09 16:30  

If you will look into documentation of FileExist function you will find:

 

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.

If common_flag = FILE_COMMON, then the function looks for the file in a shared folder for all client terminals \Terminal\Common\Files, otherwise the function looks for a file in a local folder (MQL4\Files or MQL4\Tester\Files in the case of testing).

 

It seems that FileExist finding files in only specified folders.

peterhw
69
peterhw 2016.11.09 17:03  
Janusz Trojca:

If you will look into documentation of FileExist function you will find:

 

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.

If common_flag = FILE_COMMON, then the function looks for the file in a shared folder for all client terminals \Terminal\Common\Files, otherwise the function looks for a file in a local folder (MQL4\Files or MQL4\Tester\Files in the case of testing).

 

It seems that FileExist finding files in only specified folders.

Janusz - thank you

I had seen this but didn't really understand so have tried both of the following and get the same result - i.e. not found

Do you understand that I can NOT access this file location 

(the 5002 error suggests a name error but could obviously mean the path  - I guess) 

if ( FileIsExist(myfile_name_and_path,0) )
if ( FileIsExist(myfile_name_and_path,1) )


 

whroeder1
14242
whroeder1 2016.11.09 17:44  
peterhw: (the 5002 error suggests a name error but could obviously mean the path  - I guess) 
The 5002 states that "C:\Users\user\AppData\Roaming\MetaQuotes\Terminal\9ACB2E2CE0389240C909714389C79575\MQL4\Files\C:\Users\user\AppData\Roaming\MetaQuotes\Terminal\9ACB2E2CE0389240C909714389C79575\logs\20161108.log does not exist because there is no subfolder "C:" under Files.
InvestSoft
8355
Janusz Trojca 2016.11.09 18:05  

You should only pass filename (not full path) for FileIsExist function. You can't check/find files in folder other than those mentioned in documentation.

If you need to search/check files in other folder, you need to use WinAPI functions. 

Rimantas Petrauskas
3011
Rimantas Petrauskas 2016.11.21 09:54  

Peter, MetaTrader allows to access only files from the folder "MQL5\files" (or testing_agent_directory\MQL5\files in case of testing).

Any other files are not accessible from EA or scripts because of security.

If you want to access the files outside MQL5\Files then you need to use WinAPI functions like Janusz told.

peterhw
69
peterhw 2016.11.21 11:30  
Rimantas Petrauskas:

Peter, MetaTrader allows to access only files from the folder "MQL5\files" (or testing_agent_directory\MQL5\files in case of testing).

Any other files are not accessible from EA or scripts because of security.

If you want to access the files outside MQL5\Files then you need to use WinAPI functions like Janusz told.

Many thanks all
Keith Watford
Moderator
9544
Keith Watford 2016.11.21 12:13  
Rimantas Petrauskas:

Peter, MetaTrader allows to access only files from the folder "MQL5\files" (or testing_agent_directory\MQL5\files in case of testing).

Any other files are not accessible from EA or scripts because of security.

If you want to access the files outside MQL5\Files then you need to use WinAPI functions like Janusz told.

This is MQL4, so are not likely to find in MQL5 folders
peterhw
69
peterhw 2016.11.21 15:09  
Keith Watford:
This is MQL4, so are not likely to find in MQL5 folders
Keith - I understand and yes I was using MT4
/
To add comments, please log in or register