File Path out of Terminal folder

 

Hi!


I want to create a file but not in the terminal folder but out of it. My code  works when I dont use a long path ("C:\Users\probe.csv"), but if I do, than it does not work.  What is the problem?



datetime timecount=TimeHour(TimeLocal());
int iHandle;
 
           datetime iDateTime;
           double iAccountNumber;
           string iAccountCurrency;
           double iEquity;
           double iBalance;
           double iMargin;
           double iFreeMargin;
           double iProfit;
           double iTotal;
 
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void start()
  {
 
if(timecount!=TimeMinute(TimeLocal()))
         { 
            timecount=TimeMinute(TimeLocal());
           
            iDateTime=TimeLocal();
            iAccountNumber=AccountNumber();
            iAccountCurrency=AccountCurrency();
            iEquity=AccountEquity();
            iBalance=AccountBalance();
            iMargin=AccountMargin();
            iFreeMargin=AccountFreeMargin();
            iProfit=AccountProfit();
            iTotal=OrdersTotal();
        
 
            iHandle = FileOpen("C:\Users\probe.csv",FILE_CSV|FILE_READ | FILE_WRITE);
            FileSeek(iHandle, 0, SEEK_END); 
            FileWrite(iHandle,iDateTime,iAccountNumber,iAccountCurrency,iEquity,iBalance,iMargin,iFreeMargin,iProfit,iTotal);
            FileClose(iHandle);
 
 
                    
          }
 
 
 
  }
 
roley: I want to create a file but not in the terminal folder but out of it. My code  works when I dont use a long path ("C:\Users\probe.csv"), but if I do, than it does not work.  What is the problem?

You should read the documentation when in doubt:

FileOpen

The function opens the file with the specified name and flag.

....

Note

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.

PS! Your code seems to be MQL4, so I provided the MQL4 version, but the same applies to MQL5 too.