FileWrite / FileWriteArray Only Appens.
- www.mql5.com
Also, if the new array data is less then the previously written, then the file size is not reduced, and when reading it back it will read all the older extra data as well.
So, in those cases you will have to close the file and reopen it for WRITE only, and the seeking will no longer be necessary.
EDIT: As per documentation ...
There are some specific features of work when you specify read and write flags:
- 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.
Can't be done. You are reading a text file, the positioning will be variable.
Read the file into an array, delete out of the array, reopen the file for writing and write the array.
The reading part I get but when I try to Write with one less in the array it appends the array insted of deleting the contend and then writing with this new array size.
Do I need to FileOpen -> Do the reading part of the code -> FileClose THEN FileDelete THEN OpenFile -> FileWrite with the new array?
this is what I have.