简体   繁体   中英

Is there any way to List all the files present in a folder using Javascript without using any HTML tags?

I am trying to automate an Angular application using Protractor and I came across a scenario where I need to list all the files present inside a folder.

I know in Java we can use the following:

File f = new File('D:\Practice');
ArrayList<String> names = new ArrayList<String>(Arrays.asList(f.list()));

But i couldnt get a solution in Javascript.

Node.js File System readdirSync
https://nodejs.org/dist/latest-v10.x/docs/api/fs.html#fs_fs_readdirsync_path_options

var fs = require('fs');
var files = fs.readdirSync('/tmp'); // returns list of filename as an array

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM