SD-CARD-LIBRARY - Spark-SpeedTest.cpp - Change directory

Hi,

somebody could please help me with an example opening a different folder than the root one?

having a look inside SdFile.cpp definition i understand i would need something like:

SdFile path;
SdFile file;

path.init();
path.openfolder("myflolder");

if (!file.open(&path, "pic.jpg", O_RDWR)) {
    error("open failed");
  }

but i dont see which method to use to change directory

Thanks!

@Clorofilla,

try changing this line: path.openfolder("myflolder"); to something like path.openfolder("/subfolder");

? :slight_smile:

Hi @kennethlimcp

this part of code is made up just for the purpose of explaining what im trying to do :slight_smile:

path.init();
path.openfolder("myflolder");

what i would need to know, if it’s possible, is how to open a folder with SdFile so that i can pass the instance opening a file.

Look at this line: https://github.com/technobly/SparkCore-SD/blob/master/libraries/SD/examples/Spark-ReadWrite.cpp#L60

You should probably just need to change the path to achieve that…