How can I shift the handle to the end of an openned csv file?

 

Hi there,

I am trying to open a csv file and add some information to the end of it.

I use for example:

string filename="test.csv";
int Handle=FileOpen(filename,FILE_CSV|FILE_WRITE,';');

to open a csv file and:

string date=TimeToStr(TimeLocal(),TIME_DATE);
string time=TimeToStr(TimeLocal(),TIME_SECONDS);
int write_handle=FileWrite(Handle,date,time,"EA ATTACHED TO CHART");

to write local time and date to it and at the end:

FileClose( Handle );

to close my file.

MY PROBLEM IS THAT WHENEVER EA OPENS THE FILE IT'S FILE HANDLE WILL RESET TO THE START OF FILE AND WHATEVER I WRITE BASICALLY OVER-WRITES THE FILE.

SO HOW CAN I SHIFT THE HANDLER TO THE END OF FILE SO IT WOULD APPEND THE NEW DATA TO THE EXISTING FILE?

thank you for your help.

 

https://docs.mql4.com/files/FileOpen


Maybe you need changed:

int Handle=FileOpen(filename,FILE_CSV | FILE_READ | FILE_WRITE,';');
if(Handle>0)
  FileSeek(handle, 0, SEEK_END);
 

Thanks dude for your help. :)

Reason: