Access to individual subfolders

 

Hi there,

I would be glad if someone could me  help out: I want to organize the common/file directory into input and output subfolders, in order to read files there accordingly by my EAs. The manual says "The name of the file can contain subfolders". But it seems that I am missing something there.

 The following works fine for "MetaQuotes\Terminal\Common\Files":

filename=  "Test.csv";
filehandle = FileOpen (filename, FILE_CSV|FILE_READ|FILE_COMMON, ",");

But the following example gives me an 5002-Error for file in the new folder "MetaQuotes\Terminal\Common\Files\INPUT\test.csv" (not 5004 ?!):

filename=  "\\INPUT\\Test.csv";
filehandle = FileOpen (filename, FILE_CSV|FILE_READ|FILE_COMMON, ",");

From my understanding I dont need to address TerminalInfoString(TERMINAL_COMMONDATA_PATH) . Did not work either.


The solution is certainly simple, but I could not find a clue in the forum - any help would be greatly appreciated!

 

Hi,


I think that you don't need to put the first "\\" :

filename=  "INPUT\\Test.csv";
filehandle = FileOpen (filename, FILE_CSV|FILE_READ|FILE_COMMON, ",");
 
Mounir Cheikh:

Hi,


I think that you don't need to put the first "\\" :

Hi,

thanks for replying! Tried this, but now I get a 5004 error - the file is definitely there?!

 

Ok, then try to print the path and see if it's correct :

Print(TerminalInfoString(TERMINAL_COMMONDATA_PATH)+"\\"+"INPUT\\Test.csv"); 
 
Fin2017:

Hi there,

I would be glad if someone could me  help out: I want to organize the common/file directory into input and output subfolders, in order to read files there accordingly by my EAs. The manual says "The name of the file can contain subfolders". But it seems that I am missing something there.

 The following works fine for "MetaQuotes\Terminal\Common\Files":

But the following example gives me an 5002-Error for file in the new folder "MetaQuotes\Terminal\Common\Files\INPUT\test.csv" (not 5004 ?!):

From my understanding I dont need to address TerminalInfoString(TERMINAL_COMMONDATA_PATH) . Did not work either.


The solution is certainly simple, but I could not find a clue in the forum - any help would be greatly appreciated!

You have to use the file name without "\\" at the beginning as @Mounir Cheikh said. If you got 5004 error that probably means that the file isn't in the destination directory. You have to create the file in that directory manually or you can use this code to create it.

filename=  "INPUT\\Test.csv";
filehandle = FileOpen (filename, FILE_CSV|FILE_READ|FILE_WRITE|FILE_COMMON, ",");
if(filehandle!=INVALID_HANDLE) FileClose(filehandle);
else printf("Last error: %d",GetLastError());
 

Hi,

thanks to you guys for the help, problem solved! The file was correctly placed but I made a mistake within a bool logic before that.

Lessons learned: Stop coding, when you are tired ;-)

Successfull trading to you!

F.