Arduino SD.remove()
Description
The SD.remove() function removes a file from the SD card.
Syntax
SD.remove(filename)
Parameters
- filename: the name of the file to remove, which can include directories (delimited by forward-slashes, /)
Returns
- true: if the file is removed successfully.
- false: if the file is NOT removed successfully.
- If the file didn't exist, the return value is unspecified
Example Code
/*
* Created by ArduinoGetStarted.com
*
* This example code is in the public domain
*
* Tutorial page: https://arduinogetstarted.com/reference/library/arduino-sd.remove
*/
#include <SD.h>
#define PIN_SPI_CS 4
File file;
void setup() {
Serial.begin(9600);
if (!SD.begin(PIN_SPI_CS)) {
Serial.println(F("SD CARD FAILED, OR NOT PRESENT!"));
while (1); // don't do anything more:
}
Serial.println(F("SD CARD INITIALIZED."));
SD.remove("arduino.txt"); // delete the file if existed
}
void loop() {
}
Tutorials
See Also
※ ARDUINO BUY RECOMMENDATION
Arduino UNO R3 | |
Arduino Starter Kit |
Disclosure: Some links in this section are Amazon affiliate links. If you make a purchase through these links, we may earn a commission at no extra cost to you.
Additionally, some links direct to products from our own brand, DIYables .
Additionally, some links direct to products from our own brand, DIYables .