2015-05-06 108 views
0

我想使用writeLog將directoryEntry的名稱存儲到文本文件中。但它似乎無法寫入DOMString類型(directoryEntry.name的數據類型)。cordova s​​tore fileEntry name to string

這是我的代碼的代碼

window.resolveLocalFileSystemURL(cordova.file.externalRootDirectory, function(dir) { 
    console.log("got main dir",dir); 
    dir.getFile("log.txt", {create:true}, function(file) { 
     console.log("got the file", file); 
     logOb = file; 
     var dirName = dir.name; 
     var dirPath = dir.fullPath; 
     writeLog("App started"+dirName+", path"+dirPath); 
    }); 
}); 

結果上面

App started, path/ [Wed May 06 2015 08:24:37 GMT+007 (WIB)] 

會很高興,如果有人可以提供幫助。謝謝

original code

回答

0

試試這個

function getRootDirSuccess(dirEntry) { 
    // Get a directory reader 
    var directoryReader = dirEntry.createReader(); 
    // Get a list of all the entries in the directory 
    directoryReader.readEntries(dirReadSuccess, myKnovel.page.fail); 
} 

function dirReadSuccess(entries) { 
    if (entries.length > 0) { 
     for (var i = 0; i < entries.length; i++) { 
     if (entries[i].isDirectory) { 
      console.log("it is a directory and the name is",entries[i].name); 
     } else { 
      console.log("it is not a directory and the name is",entries[i].name); 
     } 
     } 
    } 
} 
+0

對不起,我嘗試WRITELOG()結果到一個文本文件中。不在控制檯/屏幕上顯示它。無論如何謝謝你的回答 – nsampluk