Please help: MT4 FileOpen Error 5002 but file path and name is valid

 

Hi

I am getting a 5002 invalid file name error. PFA part of the EA source file with single function for this file handling code only. Also attached is the log from Print for this EA file.


I debugged the following - 

1. Verified that the path printed in the log exists - C:\Users\HOME\AppData\Roaming\MetaQuotes\Terminal\2F848ED77F2ED5C575A7E0D021C77C0B\MQL4\Files

2. I can manually create txt file from notepad into the Files folder

3. I tried with MT4 for VantageFX and Pepperstone on live account login - made no difference

4. Tried running on a different computer - made no difference


Please help to resolve this issue. I am really stuck with this with my EA  


Thanks and Regards

Afzal

Files:
 
  1. Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
              General rules and best pratices of the Forum. - General - MQL5 programming forum?
    Next time, post in the correct place. The moderators will likely move this thread there soon.

  2.    fileName = terminalDataPath + "\\MQL4\\Files\\simple2.txt";                
       fileHandle = FileOpen(fileName,FILE_WRITE|FILE_TXT);

    Perhaps you should read the manual.
       How To Ask Questions The Smart Way. (2004
          How To Interpret Answers.
             RTFM and STFW: How To Tell You've Seriously Screwed Up.

    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)
    FileOpen - File Functions - MQL4 Reference

    All file operations are confined to the sandbox. Just open "simple2.txt"

    You are trying to open " C:\Users\HOME\AppData\Roaming\MetaQuotes\Terminal\2F848ED77F2ED5C575A7E0D021C77C0B\MQL4\Files \ C:\Users\HOME\AppData\Roaming\MetaQuotes\Terminal\2F848ED77F2ED5C575A7E0D021C77C0B\MQL4\Files \MQL4\Files\Simple2.txt" which does not exist.


Reason: