Read file from another MT4 folder

[Deleted]  

Hi,

I'm trying to read a text file from another MT4 folder without success,

input string InpFileName="server.txt"; // file name 
input string InpDirectoryName = "C://Users//dan//AppData//Roaming//MetaQuotes//Terminal//BB190E062770E27C3E79391AB0D1A117//MQL4//Files//Data"; // Folder name

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
return 0;
//---
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   Run();
  }
//+------------------------------------------------------------------+

void Run()
{

   ResetLastError(); 
        int file_handle = FileOpen(InpDirectoryName + "//" + InpFileName, FILE_CSV|FILE_READ|FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_COMMON);
   if(file_handle!=INVALID_HANDLE) 
     { 
      //--- additional variables 
      int    str_size; 

      
      //--- read data from the file 
      while(!FileIsEnding(file_handle)) 
        { 
         //--- find out how many symbols are used for writing the time 
         str_size=FileReadInteger(file_handle,INT_VALUE); 
         //--- read the string 
         str=FileReadString(file_handle,str_size); 
         
         //--- print the string 
        
         
        } 
      //--- close the file 
      FileClose(file_handle); 
     } 
   else 
      PrintFormat("Failed to open %s file, Error code = %d",InpFileName,GetLastError()); 


}


//+------------------------------------------------------------------+ 
//| Script program start function                                    | 
//+------------------------------------------------------------------+ 
 

 someone can help me?

thanks

Roi

 

You don't need to specify all the path :

input string InpDirectoryName = "C://Users//dan//AppData//Roaming//MetaQuotes//Terminal//BB190E062770E27C3E79391AB0D1A117//MQL4//Files//Data"; // Folder name
 
roi.finish:

Hi,

I'm trying to read a text file from another MT4 folder without success,

 someone can help me?

thanks

Roi

I'm not sure, but your format might be off...

compare my data path to yours...


"C:\Users\Office Asus\Desktop\Trading\MT4"

v.

"C://Users//dan//AppData//Roaming//MetaQuotes//Terminal//BB190E062770E27C3E79391AB0D1A117//MQL4//Files//Data"

Maybe "C:\Users\dan\AppData\Roaming\MetaQuotes\Terminal\...\MQL4\Files\Data" will work.
 
Todd Geiger:

I'm not sure, but your format might be off...

compare my data path to yours...


"C:\Users\Office Asus\Desktop\Trading\MT4"

v.

Sometimes I am really wondering if it's worth to answer, as it seems some people can't even read.

"/" or "\" doesn't make any difference.

[Deleted]  

Thanks for your comments,

but the concept of the MT4 is that it can't reach other folders which are not in the MT4 folders only,

this is why I'm asking....