Javascript Phonegap-读取子目录?

Javascript Phonegap-读取子目录?,javascript,android,eclipse,cordova,Javascript,Android,Eclipse,Cordova,我正在使用Phonegap/Cordova 2.2 我试图读取子目录的内容,但不知道如何读取 这是我的密码: window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess, fail); function onFileSystemSuccess(fileSystem) { var tmpPath = "dir1/dir2/"; fileSystem.root.getDirectory(tmpPath

我正在使用Phonegap/Cordova 2.2

我试图读取子目录的内容,但不知道如何读取

这是我的密码:

 window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess, fail);

function onFileSystemSuccess(fileSystem) {

var tmpPath = "dir1/dir2/";

fileSystem.root.getDirectory(tmpPath, {create: false, exclusive: false}, getDirSuccess, fail);           
}


function getDirSuccess(dirEntry) {

// Get a directory reader
var directoryReader = dirEntry.createReader();

// Get a list of all the entries in the directory
directoryReader.readEntries(readerSuccess,fail);
}
如果我只获取一个目录路径,那么它可以工作;如果我尝试获取一个包含两个目录的路径,那么它将失败

任何帮助都将不胜感激


谢谢

你可以这样做:

function onFileSystemSuccess(fileSystem) {
    var tmpPath = filesystem.root.fullPath + "/dir1/dir2";
    window.resolveLocalFileSystemURI(tmpPath, getDirSuccess, fail);           
}

但我很好奇为什么你显示的代码不起作用。您在哪个平台上测试?

哪个部件出现故障?
getDirectory
调用或
readEntries
调用?我正在Android上工作。我解决了这个问题。。。我犯了愚蠢的错误。第二个文件夹不存在,我认为它会生成文件夹,但我有“创建:假”,我把它改为“创建:真”,一切都很好。很抱歉希望这个帖子能帮助其他人避免同样的错误。西蒙,我也读了很多关于PhoneGap的博客和帮助文章,很棒的贡献者!好的,很酷很高兴知道。我只是想看看是否需要修复Android端的一个bug。