NativeScript:筛选文件夹

NativeScript:筛选文件夹,nativescript,Nativescript,我想获取文件夹(位于SD卡中)的内容列表并将其放入数组中,并将文件夹与文件分开 现在我用的是: const fs=require(“tns核心模块/文件系统”); const root=android.os.Environment.getExternalStorageDirectory().getAbsolutePath().toString(); dir=fs.path.join(根“/Parole”); 让documents=fs.Folder.fromPath(dir); document

我想获取文件夹(位于SD卡中)的内容列表并将其放入数组中,并将文件夹与文件分开

现在我用的是:

const fs=require(“tns核心模块/文件系统”);
const root=android.os.Environment.getExternalStorageDirectory().getAbsolutePath().toString();
dir=fs.path.join(根“/Parole”);
让documents=fs.Folder.fromPath(dir);
documents.getEntities()
。然后((实体)=>{
实体。forEach((实体)=>{
控制台日志(实体);
});
}).catch((错误)=>{
console.log(err.stack);
});
但是
实体
contanis没有信息,但是
名称和路径
对于文件夹(以及没有EXT的文件),我如何识别它是否指向文件夹

(注意,我的项目中没有使用任何框架)


(另外,我的项目中有些文件没有任何EXT!!!!)

使用
文件夹
API区分文件夹和文件

entities.forEach((entity) => {
    if (fs.Folder.exists(entity.path)) {
       // Folder
    } else {
       // File
    }
});

使用
文件夹
API区分文件夹和文件

entities.forEach((entity) => {
    if (fs.Folder.exists(entity.path)) {
       // Folder
    } else {
       // File
    }
});