Hello friends.
I try to create a function that will delete all files on my SD card.
I already found some good answers in other posts in this forum but i am still struggling.
I used this function:
void resetlogPopCallback(void *ptr)
{
char file_Name[12] = {'f','i','l','e','_',0x00,'.','t','x','t'};
for (int i = 0; i < 100; i++) {
sprintf(file_Name, "file_%d.txt", i);
//Serial.println(file_Name);
boolean fileFLAG = SD.exists(file_Name);
if (fileFLAG) {
SD.remove(file_Name);
Serial.println("deleted");
}
}
}
My problem now is, that “fileFLAG” is never true. So no deletes will be made.
The names of the files on my SD card are following:
file_0.txt
file_1.txt
file_2.txt
…
…
… and so on
my Serial.print of the filesnames are:
file_0.txt
file_1.txt
file_2.txt
file_3.txt
file_4.txt
So they are equal imo. I dont understand whats wrong
Any ideas?
Thank you very much!