FileIsExist return error 5002 (file not found)

 

I'm trying to copy a temporary .tpl file that I saved using the ChartSaveTemplate function into the Files directory. The .tpl file located in the templates directory of the Terminal directory.

The problem is that I'm trying to find this .tpl file (that exists in the templates directory of my Terminal directory) by the function FileIsExist but no matter what path I'm adding into it, it always returning failed 5002.

For example:

string tpl_flename = "template1.tpl";

ChartSaveTemplate(0,tpl_flename);

string full_tpl_flename = TerminalInfoString(TERMINAL_DATA_PATH)+"\\templates\\"+tpl_flename;

if (!FileIsExist(full_tpl_flename)) { 

      Print ("Failed - ", GetLastError()); ======>>>>> return Failed 5002

      return false; 

}


BTW all of this problem started just after the new MT4 build 1170 (released on last December 2018).

Before this release, I could save the template file directly into the Files directory with no problem using the ChartSaveTemplate, but in the new build 1170 it' impossible.


Can someone help?

Thanks.

 
The extension "tmp" is ignored and it's saved as the file name "template1.tpl".
 
Naguisa Unada:
The extension "tmp" is ignored and it's saved as the file name "template1.tpl".

Thanks, I just wrote here tmp by mistake, in the source it's indeed "template1.tpl", however, the problem is still exists..

(I edit right now this mistake above, so next visitors will see "template1.tpl")

Any suggestions?

 

Forum on trading, automated trading systems and testing trading strategies

question about ChartApplyTemplate

Alain Verleyen, 2019.01.10 15:58

That's not exact, use the correct syntax and fix your code.


 

I found the solution!

To find the template file by using the FileIsExist function, save the template file in the Files folder - ChartSaveTemplate(0,"/Files/tmp.tpl");

BTW, In the old builds, I used to save the template with something like this: ChartSaveTemplate(chartID,"../MQL4/Files/tmp.tpl");

This syntax is no more working at the new build 1170.

So use the syntax as wrote above: ChartSaveTemplate(0,"/Files/tmp.tpl");