Pages: [1]   Go Down
Author Topic: Delete files on SD card  (Read 1202 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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");
}
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 614
Posts: 49365
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
    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:
  char filname = root.openNextFile();
This is clearly wrong. The openNextFile() method does not return the opened file's name as a single character.
Logged

Pages: [1]   Go Up
Jump to: