Reputation: 45
In HTML5, we can create a reader on a DirectoryEntry to list all the files and folders for that folder. But I want to get all the files for a directory including all subdirectories, does anyone has any idea?
Upvotes: 0
Views: 271
Reputation: 83
Sorry for the long delay, to get all files for a directory including all subdirectories, use this:
var numDirs = 0;
var numFiles = 0;
function loadDirEntry(_chosenEntry) {
var directoryReader = _chosenEntry.createReader();
directoryReader.readEntries(readerSuccess, errorHandler);
}
function readerSuccess(entries) {
var i;
for (i = 0; i < entries.length; i++) {
if (entries[i].isFile === true) {
numFiles++;
displayFiles(entries[i]);
} else if (entries[i].isDirectory === true) {
numDirs++;
loadDirEntry(entries[i]);
}
}
}
Hope this help!
Upvotes: 1