FileIsExist un expected return

To add comments, please log in or register
samjesse
645
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?

  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)){
Alain Verleyen
36103
Alain Verleyen  
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 ?
samjesse
645
samjesse  
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
To add comments, please log in or register