让我们假设我在android中有一个文件夹,它可能在内部或外部存储: “VIKAS KOHLI”文件夹,我想检查“VIKAS KOHLI”是否有任何.mp4文件。 那我该如何使用cordova来检查?如何检查此/任何文件夹是否包含任何mp4文件或不在android中使用cordova?
在此先感谢!
让我们假设我在android中有一个文件夹,它可能在内部或外部存储: “VIKAS KOHLI”文件夹,我想检查“VIKAS KOHLI”是否有任何.mp4文件。 那我该如何使用cordova来检查?如何检查此/任何文件夹是否包含任何mp4文件或不在android中使用cordova?
在此先感谢!
您需要使用File插件。一些基本的例子代码在这里:
window.resolveLocalFileSystemURL(DIR_FULL_PATH, function(dirEntry) {
var directoryReader = dirEntry.createReader();
console.log(dirEntry);
// Get a list of all the entries in the directory
directoryReader.readEntries(success,fail);
});
function success(entries) {
var i;
for (i=0; i<entries.length; i++) {
//Here you can check the entries ofject for the file name and do stuff
console.log('En - ', entries[i]);
}
}
function fail(error) {
console.log("Failed to list directory contents: ", error);
}
是的,我了解这一点。但是,我在DIR_FULL_PATH中搜索,如何获得这个目录路径,我也只是检查特定扩展的文件 –
https://www.airpair.com/ionic-framework/posts/ionic-file-browser-app此链接使用Ionic ,但你也许能够使它为你工作? –
打开该文件夹,看到:P。嗨,老兄!在这里我们可以至少解决你的问题。你的问题让我创建一个新项目:( –
我必须给用户,他在浏览目录的浏览按钮,然后在那之后我必须检查选择的目录中包含MP4文件或不 –