FileIsExist un expected return

 

Hi

This code is expected to print "found" since the file being searched for "2018822.txt" is located in the terminal Common/Files, but instead it is printing "not found". Any idea why and how to find if the file exists?

  string fileName;
  MqlDateTime tStruct;
  TimeGMT(tStruct);
  StringConcatenate(fileName, (string)tStruct.year, (string)tStruct.mon, (string)tStruct.day);
 Print(fileName):   // 2018822
 if(!FileIsExist(fileName, FILE_COMMON)){
    Print("not found");
  } else {
    Print("found"); 
  }


Also tried this

 if(!FileIsExist(StringAdd(fileName,".txt"), FILE_COMMON)){
 
samjesse:

Hi

This code is expected to print "found" since the file being searched for "2018822.txt" is located in the terminal Common/Files, but instead it is printing "not found". Any idea why and how to find if the file exists?


Also tried this

Please think about what you are doing. If your file is "2018822.txt", obviously you need to add ".txt" in the filename. However your way to do it is not good. The file name you pass to FileIsExist() is the result of the StringAdd() function. What is the return value for this function ?
 
Alain Verleyen:
Please think about what you are doing. If your file is "2018822.txt", obviously you need to add ".txt" in the filename. However your way to do it is not good. The file name you pass to FileIsExist() is the result of the StringAdd() function. What is the return value for this function ?
Got it. Thx
Reason: