FileOpen Problem

 
Hello, I am just getting started with MT5 and I'm trying the simple script: void OnStart() { int handle = FileOpen("Z:\\test.dat", FILE_WRITE); Alert(GetLastError()); FileClose(handle); } Nothing special, just trying to create a file on my Z: drive. The Alter is there because the file is never created and I wanted to see if there was an error. I end up getting a 5002 Error, which according to the documentation is 'Invalid file name'. The filename looks pretty good to me, but maybe there's something to MT that is a bit different from the other languages I've used in the past? Any help appreciated. -- Burton Samograd http://kruhft.dyndns.org
Documentation on MQL5: Standard Constants, Enumerations and Structures / Input/Output Constants / File Opening Flags
  • www.mql5.com
Standard Constants, Enumerations and Structures / Input/Output Constants / File Opening Flags - Documentation on MQL5
 
Sorry for the bad formatting, hopefully this is better:


Hello, I am just getting started with MT5 and I'm trying the simple script:

void OnStart() { int handle = FileOpen("Z:\\test.dat", FILE_WRITE); Alert(GetLastError()); FileClose(handle); }

Nothing special, just trying to create a file on my Z: drive. The Alter is there because the file is never created and I wanted to see if there was an error. I end up getting a 5002 Error, which according to the documentation is 'Invalid file name'. The filename looks pretty good to me, but maybe there's something to MT that is a bit different from the other languages I've used in the past? Any help appreciated.

--
Burton Samograd
http://kruhft.dyndns.org

Documentation on MQL5: Standard Constants, Enumerations and Structures / Input/Output Constants / File Opening Flags
  • www.mql5.com
Standard Constants, Enumerations and Structures / Input/Output Constants / File Opening Flags - Documentation on MQL5
 

Ok, so it looks like you cannot create files outside of the "Files" directory.  That seems a bit odd; is that a security feature?

 
Yeah. You'd hate to run scripts that mess with your entire filesystem :).