Help! The File Can't be Append?

 

I saw in the MQL4 Document:

  • If FILE_READ is specified, an attempt is made to open an existing file. If a file does not exist, file opening fails, a new file is not created.
  • FILE_READ|FILE_WRITE – a new file is created if the file with the specified name does not exist.
  • FILE_WRITE –  the file is created again with a zero size.
so the file that exists can't be append? 
 
Well this is the intended behaviour. What can you read from a file that does not exist?
 
virusx1984: so the file that exists can't be append? 
Of course you can; open read/write and seek to the end.
 
WHRoeder:
virusx1984: so the file that exists can't be append? 
Of course you can; open read/write and seek to the end.

Thank you! How to seek to the end? Could you give me an example?
 
virusx1984 How to seek to the end? Could you give me an example?
  1. RTFM List of MQL4 Functions - MQL4 Documentation -> File Functions - MQL4 Documentation -> FileSeek - MQL4 Documentation
  2. RTFB MQL4 Tutorial -> File Operations - Standard Functions - MQL4 Tutorial -> FileSeek - MQL4 Documentation
  3.       int      CREATE   = FILE_WRITE|FILE_TXT|FILE_ANSI;
          int      APPEND   = FILE_READ|CREATE;
          string   fileName = WindowExpertName() + ".DBG";
          HANDLE   handle   = FileOpen(fileName, APPEND);
          if(handle != INVALID_HANDLE){
             FileSeek(handle, 0, SEEK_END);
             FileWrite(handle, s);
             FileClose(handle);
    
    Is that so hard?
Reason: