What is the default folder for reading external csv file?

 

I understand MT5 can not write file to directories other than in its own sub directory for security reason. Here, I am trying to read a file. 

I am putting a csv file, "ssTestData.csv", to the folder "C:\Users\nick\AppData\Roaming\MetaQuotes\Terminal\158904DFD898D640E9B813D10F9EB397\Files\" in  my Windows 8 computer. 

The folder path is obtained by this code:

PrintFormat("File path: %s\\Files\\",TerminalInfoString(TERMINAL_DATA_PATH));

 

Here is the code I use to read file content, but the handle value is always -1.

 

int readDataTo(double &dataFromFile[]) {
   ResetLastError();
   string directory = "C:\\Users\\nick\\AppData\\Roaming\\MetaQuotes\\Terminal\\158904DFD898D640E9B813D10F9EB397\\Files\\";
   string fileName = "ssTestData.csv";
   PrintFormat("File path: %s\\Files\\",TerminalInfoString(TERMINAL_DATA_PATH));
   int fileHandle = FileOpen(directory + fileName, FILE_READ|FILE_CSV);
   if(fileHandle == INVALID_HANDLE) {
   //C:\Users\nick\AppData\Roaming\MetaQuotes\Tester\158904DFD898D640E9B813D10F9EB397\Agent-127.0.0.1-3000\MQL5
      printf("Open file: " + fileName + " error, with handle value %d", fileHandle);
      return -1;
   }
   // preform file reading and data assemble
   
   
   return 1;
}

 

I suspect the problem is because of the wrong path and the code couldn't find the file. I also tried to use fileName directly without the "directory+", but handle value is always -1.

 

Can you please tell me where I should put the "ssTestData.csv", and how to specify the path for reading?

 

Thanks a lot!

 

You don't need to specify folder. 

If file exists in "Files" folder, this is enough:

 

int fileHandle = FileOpen(fileName, FILE_READ|FILE_CSV);
Reason: