Download MetaTrader 5

How to write to C disk directly?

To add comments, please log in or register
selnomeria
254
selnomeria  

hi.

with FileWrite, it only writes into application storage direcory (in  C:\Users\username\AppData\Roaming\MetaQuotes\Terminal\50CA3DFB510CC5A8F28B48D1BF2A5702\tester\files\ )

However, when doing


 int file_handle=FileOpen("C:/file.txt",FILE_READ|FILE_WRITE);


it doesnt create a file there. why ? (maybe windows restriction?)

Blahtech Limited
5454
James Cater  
selnomeria:

hi.

with FileWrite, it only writes into application storage direcory (in  C:\Users\username\AppData\Roaming\MetaQuotes\Terminal\50CA3DFB510CC5A8F28B48D1BF2A5702\tester\files\ )

However, when doing


 int file_handle=FileOpen("C:/file.txt",FILE_READ|FILE_WRITE);


it doesnt create a file there. why ? (maybe windows restriction?)

https://docs.mql4.com/files/fileopen

"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). If FILE_COMMON is specified among flags, the file is opened in a shared folder for all MetaTrader 4 client terminals."


"C:/file.txt" is clearly at the root of the C: file system and not under your "Terminal\50CA3DFB510CC5A8F28B48D1BF2A5702\tester\files" directory

FileOpen - File Functions - MQL4 Reference
FileOpen - File Functions - MQL4 Reference
  • docs.mql4.com
FileOpen - File Functions - MQL4 Reference
To add comments, please log in or register