File Write always write over first line New comment davidmesguerra 2017.02.17 05:19 Hi, that's the thing, I've been writing a csv file but my expert always write on the first file line, there is part of my code:void saveLog(int _index){ string file_name=Symbol()+"-LOG\\["+Year()+"-"+Month()+"-"+Day()+"].csv"; int file_handle=FileOpen(file_name,FILE_CSV|FILE_READ|FILE_WRITE,","); if(file_handle!=INVALID_HANDLE){ FileWrite( file_handle, logdata_str[_index][0], logdata_str[_index][1], logdata_str[_index][5] ); FileSeek(file_handle, 0, SEEK_END); FileClose(file_handle); } else{ Print(GetLastError()); }}I've been calling this method at the end of OnTick() function and it executes every time that _index increment in 1, but my csv file just have 1 row, no mather the _index valueThanks for your help. csv file, new data in a new line.... Help Writing to .CSV file. Problem with FileWrite etc.. Keith Watford 2017.02.17 07:08 #1 Put the FileSeek() before FileWrite() New comment
string file_name=Symbol()+"-LOG\\["+Year()+"-"+Month()+"-"+Day()+"].csv";
int file_handle=FileOpen(file_name,FILE_CSV|FILE_READ|FILE_WRITE,",");
if(file_handle!=INVALID_HANDLE){
FileWrite(
file_handle,
logdata_str[_index][0],
logdata_str[_index][1],
logdata_str[_index][5]
);
FileSeek(file_handle, 0, SEEK_END);
FileClose(file_handle);
}
else{
Print(GetLastError());
}
}
Thanks for your help.