使用PhoneGap的文件API通过SD卡的每个文件遍历 [英] traverse through each file in SD card using phonegap file api
问题描述
我想通过SD卡中的每个文件遍历所有的目录和使用的PhoneGap的文件API(这是W3C文件API实际上)子目录中。我通过观察其性质以执行一组特定的这些文件操作。我DONOT想要以顺序方式来搜索特定类型的文件,但是遍历每个文件
I want to traverse through each file in the SD card inside all the directories and sub directories using the FILE API of phonegap (which is the w3c file api actually). I have to perform a certain set of operations on these files by looking at their nature. I donot want to search for specific types of files, but traverse through each file in a sequential manner.
有人可以帮助我?只是对于穿越的必然要求基本线圈骨架将是一个很大的帮助。
Can someone please help me with this? Just a basic loop framework with the necessary requirements for the traversal would be a great help.
感谢您提前。
推荐答案
我觉得以下code应该工作:
I think the following code should work:
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/
这篇关于使用PhoneGap的文件API通过SD卡的每个文件遍历的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!