Directory

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?

Ty

This example crawls through all the sub directories : http://arduino.cc/en/Reference/FileOpenNextFile 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.begin(9600);
  Serial.println("Initializing SD card");
  pinMode(10, OUTPUT);
  if (!SD.begin(4))
  {
    Serial.println("SD card initialized successfully");
    return;
  }
  Serial.println("Error trying to initialize");
}
int pasi=1;
void loop ()
{
  fisierul_meu = SD.open("test.txt",FILE_WRITE);
  delay(3000);
  SD.mkdir("test");
  while(pasi<2)
  {
    if (fisierul_meu)
    {
      fisierul_meu.println("This file was created using Arduino");
      Serial.println("This file was created using Arduino");
      fisierul_meu.close();
    }
    else
    {
      Serial.println("Error when trying to open test.txt");  
    }
    pasi+=1;
  }
}

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:

SD.mkdir("test");
  fisierul_meu = SD.open("/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 SD.open or openNextFile on a directory. That would bring you in that directory. This is (almost) the same example from Adafruit : https://github.com/adafruit/SD/blob/master/examples/listfiles/listfiles.ino