If the file already exists in the Common folder, this should resolve the problem:
string FileName = "Taskkill.bat"; bool fileExists= FileIsExist(FileName,FILE_COMMON); if(fileExists) ...Improperly formatted code edited by moderator.
Unfortunately it still return error 5002.
string fileName = "Taskkill.bat"; bool fileExist = FileIsExist(fileName); if(!fileExist) Print("file not exist error code ", GetLastError()); else Print("file exist");
It appears that MetaTrader blocks files with the .bat or similar extensions, likely for security reasons.
I just renamed the file to .txt and also copied it to the ...\Common\Files subfolder. The code now returns true:
string fileName = "Taskkill.txt"; bool fileExists= FileIsExist(fileName , FILE_COMMON); if(!fileExists) Print("file not exist error code ", GetLastError()); else Print("file exist");
Improperly formatted code edited by moderator.
Improperly formatted code edited by moderator.
Please, always use the CODE button (Alt-S) when inserting code.
It appears that MetaTrader blocks files with the .bat or similar extensions, likely for security reasons.
I just renamed the file to .txt and also copied it to the ...\Common\Files subfolder. The code now returns true:
Improperly formatted code edited by moderator.
Yes you are correct, I change the extension and the function is working find. Will try to find a solution to this.
Sure , thank you
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi, I have a batch file that I want to check if it is exist or not in OnInit() function. I use this code to
The file is located in local data folder so I use '1' on the second parameter. Using this code the result is always false with error 5002. If I use file name without extension (Taskkill) it return error 5019 and both indicated that the file isn't found.
I then copy the batch file and paste it in the Common file folder but the result is the same with error 502 and 5019. How can I use this function correctly?