I am trying to overwrite an SD log file's entries from the beginning of the file, as a way to "delete" them after they are successfully uploaded to the cloud. This is a workaround as there isn't a way to delete specific file content, only to add to it or overwrite it (as I understand it).
After a couple of days of experimentation and debug, I am unable to overwrite any file content. I do this:
datafile.seek(58); // beginning of file content to overwrite
datafile.write(' '); // (or .print(' ') Overwrite a blank at 58 position
datafile.flush(' '); // (or .close(' ') secure the write to file
The result is that the blank space is always written to the end of the file.
Can't you write to a selected byte in an SD file? I have seen this technique recommended on the Forum.
What is the trick? I don't get it.