Download MetaTrader 5

FileOpen Problem

To add comments, please log in or register
How to use MQL5.community messages editor? Find out in the article!
kruhft
13
kruhft 2012.01.18 06:02 
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
kruhft
13
kruhft 2012.01.18 06:04  
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
kruhft
13
kruhft 2012.01.18 06:35  

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

Andrei Moraru
1160
Andrei Moraru 2012.01.18 12:25  
Yeah. You'd hate to run scripts that mess with your entire filesystem :).
To add comments, please log in or register