I have written a function that indicates the start of sending files on an SD card by printing the characters "analogData" and then each file in the SD card has its filename printed and then the data the file contains.
This function is supposed to delete the file after sending it over the Serial port, but it is not doing so.
Here is the code of the function:
Everything works except for the SD.remove(String(entry.name()).c_str()); line.
What could be the problem here?
This function is supposed to delete the file after sending it over the Serial port, but it is not doing so.
Here is the code of the function:
Code:
void sendData() {
File root = SD.open("/");
Serial.println("analogData");
int startTime = millis();
File entry;
while (File entry = root.openNextFile()) {
Serial.print("filename: ");
Serial.println(entry.name());
while (entry.available()) {
Serial.write(entry.read());
delayMicroseconds(10);
}
Serial.println("fileDone");
entry.close();
SD.remove(String(entry.name()).c_str()); // this is the line that's not working
}
Serial.println("dataDone");
root.close();
Serial.print("I,Data transfer time taken in millis: ");
Serial.println(millis() - startTime);
}
Everything works except for the SD.remove(String(entry.name()).c_str()); line.
What could be the problem here?