Go Down

Topic: SdFat - Getting a file name  (Read 167 times) previous topic - next topic

Esphios

Apr 25, 2019, 09:05 pm Last Edit: Apr 25, 2019, 09:06 pm by Esphios
Hi
I'm trying to get a long filename (a .txt) from a SD and setting it as a string, I searched trough the examples of the SdFat library and I found a code print the name, I just wat to store it. but the most far I could get was getting the assress in short unsigned int.
Code: [Select]
// List files in root directory.
  if (!dirFile.open("/", O_RDONLY)) {
    sd.errorHalt("open root failed");
  }
  while (n < nMax && file.openNext(&dirFile, O_RDONLY)) {

    // Skip directories and hidden files.
    if (!file.isSubDir() && !file.isHidden()) {

      // Save dirIndex of file in directory.
      dirIndex[n] = file.dirIndex();

      // Prints the Address of the file
      Serial.println(file.dirIndex());

      // Print the file's name.
      file.printName(&Serial);
      Serial.println();
    }
    file.close();
  }



Thanks

Esphios


Go Up