Trying to remove a file from SPIFFS

I am trying to remove a file from an ESP8266. It's not working.

#include "FS.h"

void setup() {

Serial.begin(9600);
delay (10000);

SPIFFS.remove("/mvars.cfg");
File varf = SPIFFS.open ("/mvars.cfg", "w");
  varf.close ();

varf = SPIFFS.open ("/mvars.cfg", "r");
if (!varf) {
  Serial.print("File mars.cfg is there");
}
  
}

void loop() {
  // put your main code here, to run repeatedly:

  Serial.println("Exit program, remove complete");
  delay(8000);

}

Try adding this at the beginning of the setup


  // Initialize SPIFFS
  if(!SPIFFS.begin()){
    Serial.println("An Error has occurred while mounting SPIFFS");
    while(true) yield(); // die here
  }

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.