科尔多瓦商店文件条目名称到字符串 [英] cordova store fileEntry name to string
本文介绍了科尔多瓦商店文件条目名称到字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用writeLog将directoryEntry名称存储到文本文件中。但是似乎无法写入DOMString类型(directoryEntry.name的数据类型)。
I want to store a directoryEntry name to a text file using writeLog. but it seems it cannot write DOMString type (data type of directoryEntry.name).
这是我的代码
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)]
如果有人可以提供帮助,我们将非常高兴。谢谢
would be glad if anyone can help. thank you
推荐答案
尝试一下
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);
}
}
}
}
这篇关于科尔多瓦商店文件条目名称到字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文