Error Reading csv FIle MQL5

 

Hi guys,

I already tried a ton of solution posted on this forum but my code doesn't want to work.

I'm just trying to read from a csv file, but looks like it can't open it (fd return = -1). The path of the file should be correct (I put it in TerminalInfoString(TERMINAL_DATA_PATH)). There is the code:

string testo="";
int fd;
string file_name = "Data\\test.csv";
char delimiter = ';';
int OnInit()
  {
//---
   fd = FileOpen(file_name,FILE_READ|FILE_CSV,";");
   testo = FileReadString(fd);
   Comment(testo);
   Print(fd);
   
   FileClose(fd);
      
   
   
   return(INIT_SUCCEEDED);
  }

I know the request it's a little lame, but I don't find a solution.

 
C1v3tt4:

Why have you posted in the MQL4 section??

I will move this to General.

 
C1v3tt4: The path of the file should be correct (I put it in TerminalInfoString(TERMINAL_DATA_PATH)).

Where exactly did you put it? By default it should be <dataFolder>\Files\Data\test.csv. File → Open Data Folder and verify.

 
William Roeder:

Where exactly did you put it? By default it should be <dataFolder>\Files\Data\test.csv. File → Open Data Folder and verify.

I tried to put it there, but every time I execute the code or I start debugging, I don't know why, what's inside Files folder being completely removed. How can i resolve it?

Anyway my real objective it's to send repeatedly data from a C# app that I developed to my mql code. This is the better way I thought, if you have other advice they will be very appreciated.