SD card - wipe data: Erasing data vs deleting file

How to delete data on a microSD card (UNO, wireless SD shield): Is there a method to just erasing contents of a txt file w/o deleting the file itself? I'm not sure if there's any harm to deleting the actual file, if I'm going to recreate it later.

I found this post for erasing data via truncation

Just wondering if someone has a preference or good practice reasons for erasing card data vs deleting / recreating file.

The code used for deleting the txt file I successfully used is simply:

// include the SD library:
#include <SPI.h>
#include <SD.h>

// code

SD.remove("datalog.txt"); // delete the file if existed

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.