Delete files on SD card

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

    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.

  char filname = root.openNextFile();

This is clearly wrong. The openNextFile() method does not return the opened file's name as a single character.