Skip to content

Commit 9fc018f

Browse files
authored
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.
1 parent 1c56f58 commit 9fc018f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

examples/Files/Files.ino

+5-5
Original file line numberDiff line numberDiff line change
@@ -42,29 +42,29 @@ while (!Serial);
4242
}
4343
Serial.println("initialization done.");
4444

45-
if (SD.exists("example.txt")) {
45+
if (SD.exists("/example.txt")) {
4646
Serial.println("example.txt exists.");
4747
} else {
4848
Serial.println("example.txt doesn't exist.");
4949
}
5050

5151
// open a new file and immediately close it:
5252
Serial.println("Creating example.txt...");
53-
myFile = SD.open("example.txt", FILE_WRITE);
53+
myFile = SD.open("/example.txt", FILE_WRITE);
5454
myFile.close();
5555

5656
// Check to see if the file exists:
57-
if (SD.exists("example.txt")) {
57+
if (SD.exists("/example.txt")) {
5858
Serial.println("example.txt exists.");
5959
} else {
6060
Serial.println("example.txt doesn't exist.");
6161
}
6262

6363
// delete the file:
6464
Serial.println("Removing example.txt...");
65-
SD.remove("example.txt");
65+
SD.remove("/example.txt");
6666

67-
if (SD.exists("example.txt")) {
67+
if (SD.exists("/example.txt")) {
6868
Serial.println("example.txt exists.");
6969
} else {
7070
Serial.println("example.txt doesn't exist.");

0 commit comments

Comments
 (0)