Why can't append text to the end of file?

 

Hi: 

 I have the following code which is not working:

 

file = FileOpen("Result.csv", FILE_CSV|FILE_WRITE, ";");
         if ( file > 0){
            FileSeek(file, 0, SEEK_END); 
            FileWrite(file, TimeToStr(Time[g_Shift], TIME_DATE|TIME_MINUTES), "TREND=", g_Trend, "Open Short", "SHORT_BREAK_RANGE");
            FileFlush(file);
            FileClose(file);
         } else Print("LONG SHORT_BREAK_RANGE File ERROR::::::::::::::: ", GetLastError());

Basically, I want to append those information to the end of the file. However, I only get the last one. All the previous information were erased. And no-error was reported. 

 

Is there any problem using the FileSeek(file, 0, SEEK_END) here???

 

Thanks

 
asuralm:

Hi: 

 I have the following code which is not working:

 

Basically, I want to append those information to the end of the file. However, I only get the last one. All the previous information were erased. And no-error was reported. 

 

Is there any problem using the FileSeek(file, 0, SEEK_END) here???

 

Thanks

 

Did you read the documentation for FileOpen?

If there is a need to add data to an existing file, it must be opened using combination of FILE_READ | FILE_WRITE.


 
angevoyageur:

Did you read the documentation for FileOpen?



Thanks for your help. Now the problem solved. 
Reason: