[SD]
描述
Reports the next file or folder in a directory.
語法
file.openNextFile()
參數
file
: an instance of the File class (returned by SD.open())
回傳
the next file or folder in the path
範例
#include <SD.h> File root; void setup() { Serial.begin(9600); SD.begin(); root = SD.open("/"); printDirectory(root, 0); Serial.println("done!"); } void loop() { // nothing happens after setup finishes. } void printDirectory(File dir, int numTabs) { while(true) { File entry = dir.openNextFile(); if (! entry) { // no more files Serial.println("**no more files**"); } for (uint8_t i=0; i<numTabs; i++) { Serial.print('\t'); } Serial.print(entry.name()); if (entry.isDirectory()) { Serial.println("/"); printDirectory(entry, numTabs+1); } else { // files have sizes, directories do not Serial.print("\t\t"); Serial.println(entry.size(), DEC); } entry.close(); } }
也可以看看
函式庫參考主頁面
86Duino 參考的文本是根據 Creative Commons Attribution-ShareAlike 3.0 License,部分文本是從 the Arduino reference 修改的。 參考中的代碼示例已發佈到公共領域。