SD.remove() and SD.exists() do not take string variables?

When I try to call the SD.exist() or SD.remove() functions with a specified filename as the argument, these functions compile fine and work fine, e.g. SD.exist("data.txt") and SD.remove("data.txt").

However, if I use a String variable as an argument, e.g.

String datafile = "data.txt";
SD.remove(datafile);

I get a compilation error that says:

"no matching function for call to 'SdFat::remove(String&)'"

I'm not sure if this is a limitation of the SD and SDfat library, or if there is something else that I am doing wrong.

They probably take an array of character 'string', so convert your String to one of those.

They have been defined to take strings - i.e. null-terminated C-style strings which is why "data.txt" works.
They have not been defined to handle Strings.

Pete