我想使用phonegap的文件API (实际上是w3c文件api )遍历SD卡中所有目录和子目录中的每个文件。通过查看这些文件的性质,我必须对它们执行一组特定的操作。我不想搜索特定类型的文件,而是按顺序遍历每个文件。
有没有人能帮我一下?只需一个具有遍历所需要求的基本循环框架就会有很大帮助。
提前谢谢你。
发布于 2012-11-02 20:05:12
我认为下面的代码应该可以工作:
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onRequestFileSystem, fail);
function onRequestFileSystem(fileSystem) {
var directoryReader = fileSystem.root.createReader();
directoryReader.readEntries(onReadEntries, fail);
}
function onReadEntries(entries) {
var i;
for (i = 0; i < entries.length; i++) {
if (entries[i].isFile == true) {
// ...
}
if (entries[i].isDirectory == true) {
var directoryReader = entries[i].fullPath.createReader();
directoryReader.readEntries(onReadEntries, fail);
}
}
}http://www.c-sharpcorner.com/UploadFile/e83792/filesystem-directoryentry-objects-in-phonegap/
https://stackoverflow.com/questions/12866619
复制相似问题