Hello guys. A friend of mine gave me an Ethernet Shield that has a SD card slot. I learned a little bit of how to make folders, TXT files and write on them... But i don`t know this:

How do i open a folder?

I think arduino thinks that the root folder is the SD itself. But i want to create a folder, open it, and inside that folder, create a TXT file. How do i do that?


This example crawls through all the sub directories : Or you can lengthen the path with the folder. I it possible to create and read a file called "LOG/LOG1.TXT"

#include <SD.h>
File fisierul_meu;
void setup()
  Serial.println("Initializing SD card");
  pinMode(10, OUTPUT);
  if (!SD.begin(4))
    Serial.println("SD card initialized successfully");
  Serial.println("Error trying to initialize");
int pasi=1;
void loop ()
  fisierul_meu ="test.txt",FILE_WRITE);
    if (fisierul_meu)
      fisierul_meu.println("This file was created using Arduino");
      Serial.println("This file was created using Arduino");
      Serial.println("Error when trying to open test.txt");  

This is my code. I created the TEST directory, now i want to acces it, so the file TEST.txt will be created in the TEST directory. I can`t figure it out how to use that function openNextFile()

i did it:

  fisierul_meu ="/test/test.txt",FILE_WRITE);

and this is how i created the folder, and created in the folder the txt file

Okay, I confirm that. I use "/ARDUINO/INDEX.HTM".

It is also possible to use or openNextFile on a directory. That would bring you in that directory. This is (almost) the same example from Adafruit :