Failure to open files in LittleFS with ESP8266

Hi All! While using my esp8266 board, it cannot read files in a folder. Can you show me the error in my code


#include <Arduino.h>
#include "LittleFS.h"
 
void setup() {
  Serial.begin(9600);
}
 
void loop() {
  if(!LittleFS.begin()){
    Serial.println("An Error has occurred while mounting LittleFS");
    return;
  }
  
  File file = LittleFS.open("data\\text.txt", "r");
  if(!file){
    Serial.println("Failed to open file for reading");
    return;
  }
  
  Serial.println("File Content:");
  while(file.available()){
    Serial.write(file.read());
  }
  file.close();
}

I am using PlatformIO

Try this

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