FileOpen with absolute path?!

Amirfakhredin Ghanbari  

hi guys,


wondering is there anyway to use fileopen with absolute path?!

as far as i see in help document any sort of path result with error

even if it means same subfolder as using file w.o absolute address


i tried with local address & network path

same result

getting this error

Failed to open the file by the absolute path \\PC\share\yolo.csv

Error code 5002


i appreciate your help in advance

tnX


//--- incorrect file opening method  
   string terminal_data_path=TerminalInfoString(TERMINAL_DATA_PATH); 
   string filename=terminal_data_path+"\\MQL5\\Files\\"+"fractals.csv"; 
   int filehandle=FileOpen(filename,FILE_WRITE|FILE_CSV); 
   if(filehandle<0) 
     { 
      Print("Failed to open the file by the absolute path "); 
      Print("Error code ",GetLastError()); 
     } 
Marco vd Heijden  

Not outside of the sandbox for security reasons.

Read the second line here: https://www.mql5.com/en/docs/files
Documentation on MQL5: File Functions
Documentation on MQL5: File Functions
  • www.mql5.com
For security reasons, work with files is strictly controlled in the MQL5 language. Files with which file operations are conducted using MQL5 means cannot be outside the file sandbox. the common folder for all the terminals installed on a computer - usually located in the directory C:\Documents and Settings\All Users\Application...
Marco vd Heijden  

 You could try this

Search - MQL5.community
Search - MQL5.community
  • www.mql5.com
Searching is based on morphology and is insensitive to case. All letters, no matter of their case, will be processed as lowercase. By default, our search engine shows pages, that...
William Roeder  
Amirfakhredin Ghanbari: can you point me to a direction so i can share same file with multiple instances then?!

Perhaps you should read the manual. Specifically the common flag.

Amirfakhredin Ghanbari  
William Roeder:

Perhaps you should read the manual. Specifically the common flag.

not helpful

Marco vd Heijden  
Amirfakhredin Ghanbari:

not helpful

//--- Common folder for all client terminals
   string common_data_path=TerminalInfoString(TERMINAL_COMMONDATA_PATH);
Did you read the link ? 
Amirfakhredin Ghanbari  
Marco vd Heijden:
Did you read the link ? 

i did and tried for some reason didn't work maybe due windows 10 or something i gonna change access level of windows see if it works or not

tnX

Amirfakhredin Ghanbari  
Marco vd Heijden:
Did you read the link ? 

seems any sorta path result with error

void OnStart()

  {

       string MyPath=TerminalInfoString(TERMINAL_COMMONDATA_PATH);

       int Handle=FileOpen(MyPath+"\\Yolo.csv",FILE_WRITE|FILE_CSV,",",CP_UTF8);

       FileWrite(Handle,TimeCurrent(),_Symbol,(ENUM_TIMEFRAMES)_Period,iClose(_Symbol,_Period,1));

       FileFlush(Handle);

       FileClose(Handle);

       Print(MyPath+"\\Yolo.csv");

       Print(GetLastError());

   

  }

2020.04.27 05:24:01.624 CopyTrade USDCHF,H1: 5008

2020.04.27 05:24:01.624 CopyTrade USDCHF,H1: C:\Users\user1\AppData\Roaming\MetaQuotes\Terminal\Common\Yolo.csv


Amirfakhredin Ghanbari  

darn at last found why its not working

there is no need for TerminalInfoString function


just add flag of 

FILE_COMMON

to FileOpen it automatically read/write file in common folder


i hope save other people time this as well 

tnX everyone trying to help me out

int filehandle=FileOpen(filename,FILE_WRITE|FILE_BIN|FILE_COMMON);
Documentation on MQL5: Checkup / TerminalInfoString
Documentation on MQL5: Checkup / TerminalInfoString
  • www.mql5.com
Checkup / TerminalInfoString - Reference on algorithmic/automated trading language for MetaTrader 5
WindmillMQL  
Why do you use double backslashes in the path? And why do you precede the file name with double backslash? FileOpen("Yolo.csv",...) should work just fine.
Reason: