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() { }

ARDUINO BUY RECOMMENDATION

Arduino UNO R3
Arduino Starter Kit
Please note: These are Amazon affiliate links. If you buy the components through these links, We will get a commission at no extra cost to you. We appreciate it.

※ OUR MESSAGES