From 9fc018fd5531f0b2ae11076d495dc7b63aeb0ac3 Mon Sep 17 00:00:00 2001 From: Steve <1319496+VeloSteve@users.noreply.github.com> Date: Thu, 11 Jan 2024 12:16:30 -0800 Subject: [PATCH] Update Files.ino On modern Arduinos such as the Nano ESP32 file name require a leading "/" to be recognized. This simply replaces "example.txt" with "/example.txt" in five places. --- examples/Files/Files.ino | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/Files/Files.ino b/examples/Files/Files.ino index 2df0269..56c0293 100644 --- a/examples/Files/Files.ino +++ b/examples/Files/Files.ino @@ -42,7 +42,7 @@ while (!Serial); } Serial.println("initialization done."); - if (SD.exists("example.txt")) { + if (SD.exists("/example.txt")) { Serial.println("example.txt exists."); } else { Serial.println("example.txt doesn't exist."); @@ -50,11 +50,11 @@ while (!Serial); // open a new file and immediately close it: Serial.println("Creating example.txt..."); - myFile = SD.open("example.txt", FILE_WRITE); + myFile = SD.open("/example.txt", FILE_WRITE); myFile.close(); // Check to see if the file exists: - if (SD.exists("example.txt")) { + if (SD.exists("/example.txt")) { Serial.println("example.txt exists."); } else { Serial.println("example.txt doesn't exist."); @@ -62,9 +62,9 @@ while (!Serial); // delete the file: Serial.println("Removing example.txt..."); - SD.remove("example.txt"); + SD.remove("/example.txt"); - if (SD.exists("example.txt")) { + if (SD.exists("/example.txt")) { Serial.println("example.txt exists."); } else { Serial.println("example.txt doesn't exist.");