FileOpen for writing INVALID_HANDLE

To add comments, please log in or register
samjesse
645
samjesse  

Hi

In mql5

I am getting INVALID_HANDLE when trying to open a file for writing, any idea why and how to fix it?

Thanks

void writeToFile(string str){
  int fH = FileOpen("//...//...//Common//Files//newsFF.txt", FILE_WRITE, 0);
  if(fH == INVALID_HANDLE){
    Print("File does not exist: ");
  } else {
    uint k = FileWrite(fH, str);
  }
  FileClose(fH);

}
Marco vd Heijden
Moderator
8168
Marco vd Heijden  

Did you read the documentation ?

samjesse
645
samjesse  
Marco vd Heijden:

Did you read the documentation ?

 int fH = FileOpen("//newsFF.txt", FILE_WRITE | FILE_COMMON, 0);
To add comments, please log in or register