can' write in new file: wrong file name??

 

please enlighten me.

This failes with: "wrong file name"?


      if ( result <= 0 ) handle=FileOpen("C:\Users\cas\Documents\Trading\eigEntw\forex\neg.csv",FILE_CSV|FILE_WRITE,';');
      else               handle=FileOpen("C:\Users\cas\Documents\Trading\eigEntw\forex\pos.csv",FILE_CSV|FILE_WRITE,';'); 
      if (handle<=0) {
         Alert("uups, cant open File: ",ErrorDescription(GetLastError()));
         return(false);
      }


What would be a correct filename in the folder I want?


Thanks in advance!

Carl

 

it seems that you can only open files inside the terminal's files folder (see https://docs.mql4.com/files/FileOpen). Additionally, in the "C" language the character '\' has a special meaning, which I don't know whether it is same in MQL4.

try this way:

handle=FileOpen("neg.csv",FILE_CSV|FILE_WRITE,';');
//or
handle=FileOpen("\\forex\\neg.csv",FILE_CSV|FILE_WRITE,';');  // but forex must be a folder inside the "\files\" folder of the terminal.
//or 
handle=FileOpen("/forex/neg.csv",FILE_CSV|FILE_WRITE,';');  // but forex must be a folder inside the "\files\" folder of the terminal.




//in order to access files outside the terminal folder, you have to use the windows API. Search the forum for examples of API use.
 
abstract_mind:

it seems that you can only open files inside the terminal's files folder (see https://docs.mql4.com/files/FileOpen). Additionally, in the "C" language the character '\' has a special meaning, which I don't know whether it is same in MQL4.

try this way:

aha,ok - thanks.so I'll place a link into that folder.

have a nice weekend,

Carl

 

take looksee here and "If you still need to work outside the directories (defined for safety reasons), you can call the functions of Windows OS. For this purpose, the functions of API represented in kernel32.dll library are widely used...."

.

"Additionally, in the "C" language the character '\' has a special meaning, which I don't know whether it is same in MQL4."

is used as an escape char just like C: "\n" > NL, "\t" > TB, "\\" > "\"

in editor see MQL4 Reference - Basics - Data types - Literal constants
and MQL4 Reference - Basics - Data types - String constants

an interesting page IBM Informix ESQL/C Programmer's Manual