Go Down

Topic: Delete files on SD card (Read 1 time) previous topic - next topic

cstewart000

Hi,

I am trying to right a function that clears all files on the SD card. This is my function. It doesnt do anything. help me please!

void clearSDcard()
{
  char filname = root.openNextFile();
  if(SD.exists(&filname))
  {
    SD.remove(&filname);//returns filename
    Serial.println("File removed");
  }
  Serial.println("All files deleted from card");
}

PaulS

Code: [Select]
    SD.remove(&filname);//returns filename
I hardly think that a method called remove() returns a file name as its primary purpose.

On most operating systems, you can't delete an open file. I'm not sure why you think that the Arduino would be an exception.

Code: [Select]
  char filname = root.openNextFile();
This is clearly wrong. The openNextFile() method does not return the opened file's name as a single character.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy