Reading a file from SD within a directory

Hi,

I´am having problems acessing the files within directories for reading.

How should i do this:

myFile = SD.open("wcfg\intro.txt", FILE_READ);

The problem is in the backslash on the middle or the need for backslash in the beginning.
Does someone know how to put this expression correctly?

Cheers

The backslash character in C is an escape character. If you need to use a backslash in a constant, you need to use two of them.

myFile = SD.open("wcfg\\intro.txt", FILE_READ);

This presumes that \ is actually the separator, that there is a directory named wcfg at the root level, and that the wcfg directory contains a file names intro.txt.

It´s not working

Tried this:

myFile = SD.open("wcfg\\intro.txt", FILE_READ);

and this:

myFile = SD.open("\\wcfg\\intro.txt", FILE_READ);

Do you have any idea what might be the mistake.
The code works if i put the file in the root...

A quick peak at SD.cpp reveals that the separator is /, not .

Hey PaulS !

Sorry for me being such a lazy ass :slight_smile:

Thank you for the help